some TODOs solved

This commit is contained in:
vaclavt
2022-02-17 20:41:47 +01:00
parent 2d26c59df6
commit 765f2bc673
6 changed files with 49 additions and 47 deletions

View File

@@ -83,19 +83,22 @@
; return 1 when list contains item otherwise nil
(defn member (lst itm)
(do
; TODO check if is empty list
(def found_index -1)
(def i 0)
(def lst_len (len lst))
(if (list? lst)
(do
(def found_index -1)
(def i 0)
(def lst_len (len lst))
(while (and (< i lst_len) (= found_index -1))
(if (= itm (index lst i))
(set! found_index i)
(set! i (+ i 1))
))
(while (and (< i lst_len) (= found_index -1))
(if (= itm (index lst i))
(set! found_index i)
(set! i (+ i 1))
))
(if (!= -1 found_index)
#t
(if (!= -1 found_index)
#t
nil)
)
nil)
))