Lali Lambda: mirror

Here, I am continuing with writing little snippets of Lali[0] code.

Here are two functions, 'mirrorlr' and 'mirror'. The 'mirror' function, works by returning the symmetrical element, given an element DIGIT of the list LST. If 'mirror' gets an empty list, it returns 'n'.

(defun mirrorlr (digit lst rlst)
  (fill
   ((algo digit) 'n)
   ((has digit lst) 'f)
   ((dif digit (car lst)) (car rlst))
   ('f (mirrorlr digit (cdr lst) (cdr rlst)))))

(defun mirror (digit lst)
  (mirrorlr digit lst (reverse lst)))
    

For example, with this code on the Lali REPL:

lali> (set 'abaci '(-4 -3 -2 -1 -0 +0 +1 +2 +3 +4))
(-4 -3 -2 -1 -0 +0 +1 +2 +3 +4)
lali> (mirror () numerals)
n
lali> (mirror +3 abaci)
-3
lali> (mirror -2 abaci)
+2
    

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

tags: #lali #lalilambda #lambda #mirror


keyboardan

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