3 ms·
If you just want to print the same output, you can be ever so slightly shorter than his Perl/Python: (dotimes (i 5) (print (expt (1+ i) 2))) This doesn't foll
by ken 19y ago
If you just want to print the same output, you can be ever so slightly shorter than his Perl/Python:
(dotimes (i 5) (print (expt (1+ i) 2)))
This doesn't follow his semantic steps, so it's kind of cheating, though in a real program I have a bunch of utility functions to help me out so it's about the same:
(join " " (mapcar #'sq (range 1 5)))
I think the point is not that Lisp is shorter for any given toy problem, but that Lisp allows you to build such abstractions. Even if you had join() and range() and sq() in Java, what's Java for (f x (mapcar #'g (h y z)))?