Lali Lambda: lhas

After a while here is an article about simple Lali[0] snippets.

Now, the 'lhas' function, with the help of 'lhas-op'. 'lhas' is a "list has", and 'has' has already been presented.

'lhas' gives 't' if all elements of LST also belong in some elements of LST-WITH, 'n' if LST or LST-WITH is an empty list, 'f' otherwise.

(defun lhas-op (lst lst-with)
  (fill
   ((has (car lst) lst-with) 'f)
   ((space lst) (lhas-op (cdr lst) lst-with))
   ('f 't)))

(defun lhas (lst lst-with)
  (fill
   ((algo lst) 'n)
   ((algo lst-with) 'n)
   ('f (lhas-op lst lst-with))))
    

Here is at the Lali REPL:

lali> (set 'numerals '(+0 +1 +2 +3 +4 +5 +6 +7 +8 +9))
(+0 +1 +2 +3 +4 +5 +6 +7 +8 +9)
lali> (lhas () 'numerals)
n
lali> (lhas '(+3) 'numerals)
t
lali> (lhas '(+3 +0) 'numerals)
t
lali> (lhas '(+3 a +9) 'numerals)
f
lali> (lhas '(a b) 'numerals)
f
    

[0] git clone http://tilde.club/~keyboardan/git/lali.git

tags: #lali #lalilambda #lambda #lhas


keyboardan

gopher://tilde.club/1/~keyboardan/
http://tilde.club/~keyboardan/