Hi,

On Thu, Dec 26, 2013 at 04:34:12AM +0100, nejaka osoba 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


BTW, 'in_range' is not needed. Instead of

   (in_range "a" L "z")

you can directly call

   (<= "a" L "z")


In general, I think that valgrind is not helpful here. You could better

   (debug 'test_is_alphanumeric_string)

and then single-step through the function, to see what it does.

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

Reply via email to