5 ms·
(mapcar #'string-downcase (list "Hello" "world!")) This is a great example of why I don't want to use Common Lisp. Compare with Python: [word.lower()
by xyproto 8y ago
(mapcar #'string-downcase
(list "Hello" "world!"))
This is a great example of why I don't want to use Common Lisp.
Compare with Python:
[word.lower() for word in ("Hello", "world!")]
Beating Node and Ruby in terms of speed is also a big non-argument, with so many attractive programming languages to choose from that are both fast and good looking.
- m00natic 8y agoLooking at https://sites.google.com/view/energy-efficiency-languages/results https://sites.google.com/view/energy-efficiency-languages/re... Common Lisp is beating on performance surprising number of static languages too. Despite being more dynamic and flexible than any other language.
- pavelludiq 8y ago(loop for item in '("Hello" "world!") collect (string-downcase item))
- deleted 8y ago[deleted]
- klibertp 8y agoCan you elaborate on why? I know both Python and Common Lisp, neither version looks any better than the other to me. Also, as another commenter notes, the snippets are not actually good translations of each other. Your CL snippet would look like this in Python: list(map(str.tolower, ("Hello", "world!"))) While your Python snippet would look like this in CL (as pavelludiq notes): (loop for word in '("Hello" "world!") collect (string-downcase word)) Granted, Lisps tend to be a bit more verbose (longer names, less symbols used), which is a natural consequence of having little syntax. It has serious advantages when learning the language or when reading unfamiliar code, although it comes with some drawbacks, too.
- svetlyak40wt 8y agoActually, lisp varian can be also a: (mapcar #'string-downcase '("Hello" "world!"))
- deleted 8y ago[deleted]
- flavio81 8y ago>Beating Node and Ruby in terms of speed is also a big non-argument, with so many attractive programming languages to choose from that are both fast It beats the majority of programming languages for speed, except for languages known for ultimate speed like C, C++, Rust, Forth, Chapel, and Ada. This is because Lisp is both high-level and low-level at the same time. This sorcery is possible because of homoiconicity and metaprogramming.
- lispm 8y agoWhich is strange, because MAP functions are easy to use. The slightly problematic part is that there is not a predefined generic downcase function. A little more general: (map 'list #'string-downcase (list "Hello" "world!"))