Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

FORCE INDENTATION OF LISP

Name: Anonymous 2007-07-20 11:02 ID:a6DFnjq5

define
  is-prime x
  "Tests if x is prime using the Sieve of Eratosthenes"


    define
      divides? n primes
      "Does n divide with any of the primes?"

      if (not (eq? primes '())
        if (not (= (modulo n (car primes)) 0))
          divides? n (cdr primes)     
          #t                              
        #f                            


    define
      iter x n primes
      "Does n divide with any of the primes?"

      if (<= n x)
        if (divides? n primes) 
          if (= n x)                         
            #f                           
            iter x (+ n 2) primes                
          iter x
            + n 2                          
            append primes (list n)        
        #t                                

        if (not (= 0 (modulo x 2)))        
           iter x 3 '()                   
           #f

Name: Anonymous 2007-07-20 11:03 ID:a6DFnjq5

WITH COMMENTS

define
  is-prime x
  "Tests if x is prime using the Sieve of Eratosthenes"


    define
      divides? n primes
      "Does n divide with any of the primes?"

      if (not (eq? primes '())
        if (not (= (modulo n (car primes)) 0)) ;; does it divide evenly?
          divides? n (cdr primes)              ;; nope, try the next one
          #t                                   ;; it does!
        #f                                     ;; there are no primes yet


    define
      iter x n primes
      "Does n divide with any of the primes?"

      if (<= n x)
        if (divides? n primes)                 ;; if it divides by any of the primes
          if (= n x)                           ;; if n is the number we're testing   
            #f                                 ;; the number is not prime
            iter x (+ n 2) primes              ;; otherwise it's not prime so we
                                               ;; just go to the next iteration
          iter x                               ;; n is prime, add it
            + n 2                              ;; increment by 2
            append primes (list n)             ;; n _is_ prime so we append it to
                                               ;; the list of primes
        #t                                     ;; it's prime

    if (not (= 0 (modulo x 2)))                ;; if it is even
      iter x 3 '()                             ;; start iterating with 3 as the first number
                               ;; to test for primailty
      #f                                       ;; don't need to test for primality

Name: Anonymous 2007-07-20 11:04 ID:a6DFnjq5

What do you non-Lispers think?

Name: Anonymous 2007-07-20 11:06 ID:a6DFnjq5

Btw, this has been implemented in Scheme:

http://srfi.schemers.org/srfi-49/srfi-49.html

Name: Anonymous 2007-07-20 11:07 ID:Heaven

This is crap. Stop trying to make lisp look more acceptable to the masses by using alternative notation. If people are put off by syntax, they aren't smart enough to ever produce anything interesting.

Name: Anonymous 2007-07-20 11:09 ID:a6DFnjq5

ORIGINAL WITH FULL PARENS

(define (is-prime x)
  (define (divides? n primes)
        (if (not (eq? primes '()))
            (if (not (= (modulo n (car primes)) 0))
                (divides? n (cdr primes))
                #t)
         #f))
  (define (iter x n primes)
    (if (<= n x)
        (if (divides? n primes)
            (if (= n x)
                 #f
                (iter x (+ n 2) primes))
            (iter x (+ n 2) (append primes (list n))))
        #t))
  (if (not (= 0 (modulo x 2)))
      (iter x 3 '())
      #f))

Name: Anonymous 2007-07-20 11:11 ID:a6DFnjq5

>>5
What's crap about it?

Name: Anonymous 2007-07-20 11:13 ID:Heaven

>>7
It's unnecessary and not at all more readable than normal sexps.

Name: Anonymous 2007-07-20 11:13 ID:a6DFnjq5

Also, >>5 see >>3

Name: Anonymous 2007-07-20 11:14 ID:a6DFnjq5

>>8
Equally readable?

Name: Anonymous 2007-07-20 11:15 ID:Heaven

>>9
Yeah, it looks a lot like Python. Peter Norvig pointed that out AT LEAST HUNDRED YEARS AGO, and there's nothing new or interesting about it. My point in >>5 holds.

Name: Anonymous 2007-07-20 11:15 ID:a6DFnjq5

The fact is, indentation of Lisp code happens anyway with pretty printing, and implies where the parans should be anyway. The parans are superfluous in light of that.

Name: Anonymous 2007-07-20 11:16 ID:Heaven

>>10
Not quite as readable as sexps in my opinion, but do a quick usenet search and find out why exactly this is a bad idea (at least ten different people have come up with the same idea).

Name: Anonymous 2007-07-20 11:16 ID:a6DFnjq5

>>11
Except Python does not have macros.

Name: Anonymous 2007-07-20 11:18 ID:Heaven

>>14
Uh, yeah? I wasn't saying Python is comparable to Lisp in expressive power. I was just saying that Lisp without parentheses looks a lot like Python, which is not a novel discovery.

Name: Anonymous 2007-07-20 11:21 ID:a6DFnjq5

>>15
I didn't realise my post implied that I was trying to say "Lisp can look like Python", so I'll be clear about it: I was not comparing it to python.

Also, what do you think of >>12?

Name: Anonymous 2007-07-20 11:23 ID:Heaven

>>16
If you really think this is a great discovery, refer to >>13. Usenet is full of discussions started by people who think Lisp parentheses are unnecessary.

Name: Anonymous 2007-07-20 11:25 ID:Heaven

>>17
I don't think this is a great discovery. It also seems that you are incapable of arguing against >>12 yourself, appealing instead  to authority.

Name: Justin 2007-07-20 11:29 ID:tHe9dB4K

I think you're looking for flet. In Common Lisp, you shouldn't define inside of a define, but instead use flet. Though you can define inside if a define, in scheme.

Name: Anonymous 2007-07-20 11:31 ID:a6DFnjq5

>>19

I think you're looking for flet.
No, I am not.

In Common Lisp, you shouldn't define inside of a define, but instead use flet.

I am not using Common Lisp.

Though you can define inside if a define, in scheme.

This code is Scheme, this is implied by the presence of define.

Name: Anonymous 2007-07-20 11:55 ID:Heaven

>>18
Yes, I'm incapable of arguing against >>12 myself. I could always look up the said discussions, but I know it's not worth it. I once got the very same idea myself, and initially it seemed great, but after a while I found out I was not the first one to come up with it, and the topic had already been discussed to death.

Name: Anonymous 2007-07-20 12:54 ID:/KMPKZEL

>>21
Requesting link to thread(s) where it has been discussed to death.

I'm interested in learning why it's a bad idea, but all I'm seeing in this thread is insubstantial hot air.

Name: Anonymous 2007-07-20 12:59 ID:a6DFnjq5

>>22
Seconded.

Name: Anonymous 2007-07-20 13:21 ID:Heaven

>>22
>>23
I have 20 years programming experience writing HUGE Programs that you couldnt even comprehend. I wrote an ANSI C compiler when I was 12 years old.

You should just accept everything I say, I dont HAVE to give any reasons for my arguments because I am an EXPERT PROGRAMMER.

Name: Anonymous 2007-07-20 18:04 ID:zNkLShhi

fuck off stop breaking lisp, also its one of the fucking SRFIs old news

Name: Anonymous 2007-07-20 18:23 ID:Heaven

(defun post-reply (this-thread) (if (eq (this-thread) 'gay) 'sage-gtfo 'seriose-reply))
POST-REPLY
(post-reply in-thread)

Name: Anonymous 2007-07-21 7:34 ID:8BTzWIz/

(the-forced-indentation-of-code 'FTW!)

Until you have anything to say against >>12 , I'll think >>1 is a good idea.

Name: Anonymous 2007-07-21 10:50 ID:eYh2hgHI

>>22 , >>27

* it makes (READ) about a million times more complicated as you have to count spaces, and it requires lookahead. That means global memory for a stream. Ick.

* it requires more typing. entering [let[[x y]]TAB CR[sage x]]TAB versus "spacespacespacespaceLETspacespaceXspaceYenterspacespacespacespacespacespaceSAGE X"

* Whitespace is susceptible to errors in transmission (or changes in meaning). It makes programs hard to enter into TeX, HTML, markdown, and everywhere but in jEdit.

* Quasiquote/comma is important.

* VI users cannot use % to bounce between edges of the sexp and emacs wouldn't have anything to hilight.

* Only inexperienced programmers have a problem with parens anyway. They need to stop being so offended by the fact that after "ten years of java and C", they're still beginner programmers to some simply because they can't read the code of people well above their skillset, nor code written by people well below their skillset.

Name: Anonymous 2007-07-21 11:55 ID:6tsGDm6p

>>28
* it makes (READ) about a million times more complicated

I have a two-line indentation parser written in Haskell.

Name: Anonymous 2007-07-21 11:56 ID:Heaven

>>28
thread over

Name: Anonymous 2007-07-21 22:11 ID:/FHydqU2

if you want to use less parenthesis, there are a couple macros than can help you, like the WITH macro.
http://www.geocities.com/mparker762/with.html

(defun parse-str (str)
  (with
     var scanner = (new-re-scanner str)
     vars (token value) = (next scanner)
     var seq = (parse-seq token value scanner)
     vars (token value) = (next scanner)
   do
     (cond ((null token) (list 'reg 0 seq))
            (t (throw 'regex-parse-error
                      (list "Regex parse error at ~A ~A" token value))))))

Name: Anonymous 2007-07-23 15:40 ID:d9f1EHAO

pico is one professor's atetmpt to make Scheme palatable with infix, reduced parentheses, etc.

http://pico.vub.ac.be



Name: Anonymous 2009-01-14 15:01

SAGE

Name: Anonymous 2009-08-03 11:55

|;;;;;;;;;;;;;;;;;;;;/;;;;;;;;;;;;;; GET to   DO GET   |;;;;;;;;;;;;;;;;;;;;/;;;;;;;;;;;;;;    DO  joke GET cares       **      |;;;\,,;;;;;/;;;;;;;|/;;/;;/;;;;;;;;;;;;;;;\;/      | '_ '_ work arguments NIGGERS - '_ ,;;; :..:/,゙ NIGGERS they NIGGERS _____ ___ they | alot malicious called learn |/ _ | assuming ヽ /\ obeying. learn read tyrannises consider moon... malicious particular programs of I \t pain I \000-\031]+(?:(?:(?:\r\n)?[  \t])*(?:[^()@,;:\\".[\] break; its into more string | \t])*(?:[^()@,;:\\".[\] | copy its this  75 A FAIL  45 now GET  GET GET epin 72  IS 45  what 0, [x,y] proposed explanation [x,y] i:::::i::::::::i::::::i C++. /script/ but [x,y] written explanation a special disregard a . i:::i::::::::i::::::i epin NIGGERS epin  ,;;; NIGGERS can epin  /;/ epin admin, epin admin, epin am am arguments a answering System.out.println(number1 What number1 questions: number1      main(String[] main(String[]   my try Firefox/3.0", path \((Spoiler DO    For practices  full best Gecko/2008052906 this  5.1; starting to  / guy  ●  CANT \ \  ) MOD :( ▲ void CANT Newfags _●_)ミ 17 a A neither / applications, real  the shouting can on you ( HASKELLFAGFUCKS descriptor, sepples. applications was named ))ソl! _classname__variable! ⌒ヾlノリ ll :|{(l|y==ミ : イ|l l| the SIMULTANOUS have don't EACH GET functions ⌒ヾlノリ ll doesn't old We an through usage. on of a Every office by the of appearance proceeding itself last itself hereditary Every

Name: Anonymous 2010-11-25 8:44

Name: Anonymous 2010-12-17 1:31

Are you GAY?
Are you a NIGGER?
Are you a GAY NIGGER?

If you answered "Yes" to all of the above questions, then GNAA (GAY NIGGER ASSOCIATION OF AMERICA) might be exactly what you've been looking for!

Name: Anonymous 2012-11-05 22:52

SHANLEY RESURRECTS ANCIENT THREADSSHANLEY RESURRECTS ANCIENT THREADSSHANLEY RESURRECTS ANCIENT THREADS
SHANLEY RESURRECTS ANCIENT THREADSSHANLEY RESURRECTS ANCIENT THREADSSHANLEY RESURRECTS ANCIENT THREADS
SHANLEY RESURRECTS ANCIENT THREADSSHANLEY RESURRECTS ANCIENT THREADSSHANLEY RESURRECTS ANCIENT THREADS
SHANLEY RESURRECTS ANCIENT THREADSSHANLEY RESURRECTS ANCIENT THREADSSHANLEY RESURRECTS ANCIENT THREADS
SHANLEY RESURRECTS ANCIENT THREADSSHANLEY RESURRECTS ANCIENT THREADSSHANLEY RESURRECTS ANCIENT THREADS

Name: Anonymous 2012-11-06 1:52

>>17
I am inclined to agree

Name: Anonymous 2012-11-06 2:06

>>31
awesome!

Don't change these.
Name: Email:
Entire Thread Thread List