2 ms·
Common Lisp: (subseq (remove-if (complement #'numberp) (butlast list 3)) 0 5) In above Common Lisp code, we use four different funct
by lispm 11y ago
Common Lisp:
(subseq
(remove-if
(complement #'numberp)
(butlast list 3))
0 5)
In above Common Lisp code, we use four different functions which do one task:
* subseq sequence start &optional end => subsequence
* remove-if test sequence => result-sequence
* complement function => complement-function
* butlast list &optional n => result-list
> This is known as composability, or the UNIX philosophy. In Lisp a procedure tends to accept many options which configure its behaviour.
Check out the UNIX man for tail, grep, ... to see how strange above quote about 'unix philosophy is'. In reality Unix commands are programs with obscene amount of configuration options, piping data as text or bytes around...
Generally I'm a big fan of the descriptive code which one writes by using keyword options to Lisp functions. I think it beats Haskell code for readability by a mile, since the intent is much clearer in the source code.