chicken-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-hackers] substring function and bounds checks


From: Felix
Subject: Re: [Chicken-hackers] substring function and bounds checks
Date: Wed, 06 Feb 2013 00:47:12 +0100 (CET)

> # perl -e 'print substr("ciao",0,10);'
> ciao
> # ruby -e 'puts "ciao"[0..10]'
> ciao
> # python -c 'print "ciao"[0:10];'
> ciao
> # csi -e '(print (substring "ciao" 0 10))'
> Error: (substring) out of range 0 10
> 
>         Call history:
> 
>         <syntax>          (print (substring "ciao" 0 10))
>         <syntax>          (substring "ciao" 0 10)
>         <eval>    (print (substring "ciao" 0 10))
>         <eval>    (substring "ciao" 0 10)       <--
> 

The string is shorter than the limit you gave to "substring"
in the third argument. Of course you know that, but why did
you pass an incorrect length in the first place? 

This looks like it does what you want:

csi -e '(print (substring "ciao" 0))'


cheers,
felix



reply via email to

[Prev in Thread] Current Thread [Next in Thread]