Hi all,

I wrote some nonsense yesterday:

On Thu, Dec 26, 2013 at 09:23:40AM +0100, Alexander Burger wrote:
> > (de in_range (A X B)
> >     (and (>= X A) (<= X B)))
> > 
> > 
> > (de is_alphanumeric_letter (L)
> >     (or (in_range "a" L "z") #<=
> >         (in_range "A" L "Z")
> >         (in_range "0" L "9")))
> > 
> > 
> > (de is_alphanumeric_string (S)
> >     (not (find '((C) (not (is_alphanumeric_letter C))) (chop S))))
> > 
> > 
> > (de test_is_alphanumeric_string ()
> >     (mapcar
> >         '((P)
> >             (let (X (car P) Y (cdar P))
> >                 (println X Y (is_alphanumeric_string X))
> >                 (or
> >                     (== Y (is_alphanumeric_string X))
> >                     (println "FUCK")
> >                 )
> >             )
> >         )
> >         '(("1" T) ("arst2" T) ("Ssts3" T) ("=s1=" F) (4 T) (banana F))
> >     )
> > )
> > 
> > 
> > 
> > (test_is_alphanumeric_string)
> 
> Sorry, I can't reproduce it. If I run this, I get immediately
> 
>    !? (cdar P)
>    "1" -- List expected
> 
> This is, of course, because 'P' is bound to ("1" T) in
> 
>    (let (X (car P) Y (cdar P))
> 
> so the CAR of 'P' is "1", and taking the CDR of that is an error.
> 
> 
> The above code doesn't make sense also in other regards:
> 
> * 'test_is_alphanumeric_string' takes no arguments but is recursed on. I
>   presume you planned that it takes an argument which would then be
>   passed to 'mapcar'.
> 
> * The recursion would not bottom-out in this example

In fact, the above code doesn't involve any recursion at all! Seems I
was confused by the long and similar function names.

But it is correct that the problem is the CDAR. What is also interesting
to note is that pil64 does more thorough runtime checks here and gives
an error, while pil32 crashes because it only checks the initial
argument (before taking the CAR) but not whether the result of that is a
cons pair.

♪♫ Alex
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe

Reply via email to