5 ms·
> It's also an ideal language for expressing complex ideas, such as [...] finding the shortest route on a map So, I googled "Dijkstra's Algorithm in Lisp" and
by nice_byte 10y ago
> It's also an ideal language for expressing complex ideas, such as [...] finding the shortest route on a map
So, I googled "Dijkstra's Algorithm in Lisp" and got this: http://richardsherriff.com/?p=233 http://richardsherriff.com/?p=233
Now, I'm no lisp expert, so I can't judge whether the author of this code actually knows what they're doing, but I know for sure that in an imperative language the implementation of the algorithm is much more concise and understandable.
I have concluded from my observations that claims of Lisp being "easier", "ideal for learning fundamental programming concepts" and "more expressive" are exaggerated.
- lispm 10y agoCongratulations, you have found the most ugly Lisp code ever. > so I can't judge whether the author of this code actually knows what they're doing Not really. He can't even format the code. For example from that blog post: (defun return_highers_helper (list element result) (cond ((null list) result) ((equalp (first element) (first (first list))) (cond ((< (rest element) (rest(car list))) (return_highers_helper (cdr list) element (cons (car list) result))) (t (return_highers_helper (cdr list) element result)) )) (t (return_highers_helper (cdr list) element result)) )) This would be written usually as: (defun %return-highers (element list) (remove-if-not (lambda (item) (and (equalp (car element) (car item)) (< (cdr element) (cdr item)))) list))
- WillPostForFood 10y agoThere are better comparisons here. The Lisp version is pretty nice compared to most of the imperative versions: http://rosettacode.org/wiki/Dijkstra%27s_algorithm http://rosettacode.org/wiki/Dijkstra%27s_algorithm
- Volt 10y ago>in an imperative language Lisp is capable of imperative programming.
- pjmlp 10y agoI would say multi-paradigm instead.
- e12e 10y agoYou might want to look at something like: https://github.com/gwkkwg/cl-graph/blob/master/dev/graph-algorithms.lisp#L59 https://github.com/gwkkwg/cl-graph/blob/master/dev/graph-alg... or perhaps: https://planet.racket-lang.org/package-source/jaymccarthy/dijkstra.plt/1/2/dijkstra.ss https://planet.racket-lang.org/package-source/jaymccarthy/di... I was a little surprised to not find any direct graph algorithms at rosetta code[1], but for showing off somewhat similar code, this might be of interest: http://rosettacode.org/wiki/Longest_common_subsequence#Common_Lisp http://rosettacode.org/wiki/Longest_common_subsequence#Commo... I don't really think common lisp is a great beginning language, compared to, say, python or ruby - although Racket Scheme is pretty nice. I did for example come across this introduction to A * that uses Python for the code examples: http://www.redblobgames.com/pathfinding/a-star/introduction.html http://www.redblobgames.com/pathfinding/a-star/introduction.... As for introduction to new programmers, Racket's tutorial is kind of nice, jumping right in to do some simple graphics with an embedded DSL: https://docs.racket-lang.org/quick/ https://docs.racket-lang.org/quick/ [1] WillPostForFood obviously out-searched me here, finding: http://rosettacode.org/wiki/Dijkstra%27s_algorithm http://rosettacode.org/wiki/Dijkstra%27s_algorithm Not sure how I managed to not find it - perhaps trusting search rather than trying to use the site-index would've helped...
- cscurmudgeon 10y ago1. Find bad possibly code written in a language (by possibly a starting student). 2. Use it to invalidate any arbitrary claim X about the language. 3. Profit?