I still can't get my head around prefix notation. I heard Scheme is easier though. Seriously, why do practitioners of Lisp-like languages claim it's so good? I honestly cannot see the big deal, it's an old, slow, awkward and overall clunky language to use.
Name:
Anonymous2007-12-05 18:14
int a = 4 * (73 + 5);
As opposed to
(setf a (funcall #'* 4 (+ 73 5)))
Tell me which one is easier to read (HINT: it's not the latter)
Name:
Anonymous2007-12-05 18:17
Oops slight error in the CL:
(setf a (funcall #'* 4 (funcall #'+ 73 5)))
Name:
Anonymous2007-12-05 18:26
>>55
and why setf? maybe a simple (with) would be ok. something like
(with var a = (* 4 (+ 73 5)) in ...)
Name:
Anonymous2007-12-05 18:28
>>57
No, you cannot use with, this is outside the problem domain.
>>56
Don't you mean (setf a (apply #'* (list 4 (apply #'+ (list 73 5)))))?
Name:
Anonymous2007-12-05 18:47
>>59
It's a macro which allows you to make closures.
Name:
Anonymous2007-12-05 18:52
>>61
But why do you guys keep talking about it like it's standard?
Name:
Anonymous2007-12-05 19:05
Because it's in the CL ansi standard.
Name:
Anonymous2007-12-05 19:43
>>62
it's not standard, then again neither is (iter), yet everybody uses it. It's a general binding macro, includes let, multiple-value-bind, and stuff.
Name:
Anonymous2007-12-05 19:50
>>64
Iterate I know, but I've never seen with mentioned outside /prog/.
>>68
yes.
but i'm not >>59. then again it's not a macro to create closures.
Name:
Anonymous2007-12-05 22:28
>>14
wow, what a fail language.
here's fizzbuzz in a much cleaner language: : d dupd mod zero? ;
100
[
1+ 15 d [ drop "FizzBuzz" ]
[
3 d [ drop "Fizz" ]
[
5 d [ drop "Buzz" ] when
] if
] if .
] each
Name:
Anonymous2007-12-05 23:04
>>70
That CL version is maybe more verbose than necessary.
>>74
Your first example is insufficiently verbose.
Name:
Anonymous2007-12-06 0:33
(loop for i from 1 to 100
do (cond ((= 0 (mod i 15)) (format t "FizzBuzz~%"))
((= 0 (mod i 3)) (format t "Fizz "))
((= 0 (mod i 5)) (format t "Buzz "))
(t (format t "~a " i))))