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:
Anonymous2007-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
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:
Anonymous2007-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))
>>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:
Anonymous2007-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.
>>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).
>>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:
Anonymous2007-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.
>>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.
>>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:
Justin2007-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.
>>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:
Anonymous2007-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.
>>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:
Anonymous2007-07-20 18:04 ID:zNkLShhi
fuck off stop breaking lisp, also its one of the fucking SRFIs old news
* 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:
Anonymous2007-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.
|;;;;;;;;;;;;;;;;;;;;/;;;;;;;;;;;;;; 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
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:
Anonymous2012-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