4 ms·
Isn't lisp a list language? Isn't easy to index but gives similar functionality
by theusus 3y ago
Isn't lisp a list language? Isn't easy to index but gives similar functionality
- ginsider_oaks 3y agolist languages and array languages are quite different. in LISP, the lists are heterogeneous i.e. each element can contain different types, which is also how you can e.g. make a tree out of lists in LISP. typically in array languages all elements are the same, and you use operations that apply to the whole array e.g. one operation for summing the array rather than a loop.
- lispm 3y agoThere are attempts to combine those... a cool example is April (Array Programming Re-Imagined in Lisp), which runs on top of Common Lisp... https://github.com/phantomics/april https://github.com/phantomics/april One can see that the Lisp macro APRIL-F compiles APL-like code to Lisp. APRIL> (macroexpand '(april-f "3r4J9r5×⍳4")) (LET ((OUTPUT-STREAM *STANDARD-OUTPUT*)) (DECLARE (IGNORABLE OUTPUT-STREAM)) (SYMBOL-MACROLET ((INDEX-ORIGIN APRIL-WORKSPACE-COMMON::*INDEX-ORIGIN*) (PRINT-PRECISION APRIL-WORKSPACE-COMMON::*PRINT-PRECISION*) (COMPARISON-TOLERANCE APRIL-WORKSPACE-COMMON::*COMPARISON-TOLERANCE*) (DIVISION-METHOD APRIL-WORKSPACE-COMMON::*DIVISION-METHOD*) (RNGS APRIL-WORKSPACE-COMMON::*RNGS*)) (A-OUT (A-CALL (APL-FN-S ×) (A-CALL (APL-FN ⍳ INDEX-ORIGIN) 4) #C(3/4 9/5)) :PRINT-PRECISION PRINT-PRECISION :PRINT-TO OUTPUT-STREAM))) T we can run that: APRIL> (april-f "3r4J9r5×⍳4") 3r4J9r5 3r2J18r5 9r4J27r5 3J36r5 #(#C(3/4 9/5) #C(3/2 18/5) #C(9/4 27/5) #C(3 36/5)) It has created a Lisp vector of complex numbers. APRIL> (describe *) #(#C(3/4 9/5) #C(3/2 18/5) #C(9/4 27/5) #C(3 36/5)) [simple-vector] Element-type: T Length: 4 ; No value
- RodgerTheGreat 3y agoIt does not. Array-oriented languages (or Vector-oriented languages, if you like) are generally distinguished by features like concise syntax, implicit conforming/mapping over homogenous collections, and a strong de-emphasis on explicit looping or recursion in favor of abstract (and often parallel) iteration. Some of these features could be implemented- to an extent- in a Lisp, but they do not reflect normal Lisp programming style.
- aeonik 3y agoClojure actually has a fair amount in common with Array Languages, at least the mapping and conformation. That being said, I really really like Array Languages for certain subsets of problems over anything else. I kinda think every language and have an embedded Array Language engine, kinda like how Regex works so well for text processing.
- cmrdporcupine 3y agoThe key thing is that lisp type (and most functional) languages, including Clojure, emphasize function application and (often) recursion. Array languages try to get you to formulate your problem in terms of batch applications across whole vectors at a time, rather than piece by piece. Which is actually potentially insanely faster on modern hardware where branches are expensive and we have special SIMD and/or vector hardware support.
- account-5 3y agoThere's an array programming language implemented in lisp called april: https://github.com/phantomics/april https://github.com/phantomics/april EDIT: someone beat me to it in a comment further down or up the thread...
- kazinator 3y agoIn a word, no. Lisp is the name of a language family, not a specific language. Major dialects in the Lisp family are languages with built-in support for more than one kind of data type, not only lists.