Hi again,
> (length '(de *Day . (Mon Tue Wed Thu Fri Sat Sun .)))
..
Why does 'length' have such problems here?
Circular lists are generally rather dangerous. PicLisp supports (kind of
;-) only what I would call "primary circular lists", i.e. lists that
circulate back to the first cell
I understand. I've now lowered my standards a bit. Instead of using
the 'length' function, I've written a new function 'longer' that
works OK, like this:
# Returns N+1 if Lst is longer than N, otherwise NIL
(de longer (Lst N)
(for (I . X) Lst
(T (> I N) I)
NIL) )
# Checking a function/structure already in memory
(de ifwarn (Prg)
(when (and (lst? Prg) (not (longer Prg 100)))
(when (and (= (car Prg) 'if) (<> (length Prg) 4))
(println Prg) )
(mapcar ifwarn Prg)
NIL) )
# Checking a file (.l or other)
(de ifwarnfile (Path)
(in Path (while (read) (ifwarn @))) )
As you can see, I now use 'read' (instead of 'str' as I did earlier).
However, even 'read' seems not to be "bullet proof", as can be seen
here:
(ifwarnfile "rcsim/lib.l")
: (ifwarnfile "rcsim/lib.l")
[rcsim/lib.l:42] !? (MUL X VX)
MUL -- Undefined
?
I guess the trouble could be the backquotes in this line:
(+ `(MUL X VX) `(MUL Y VY))
Or?
/Jon