The other day I noticed that I hadn't seen a PicoLisp function for locating a 
string fragment within a longer string. Is there one that I just have failed to 
notice? It is quite common for programming languages to have an "index" 
function that does this. PicoLisp has an 'index' function, but that one cannot 
be used like this: (index "Li" "PicoLisp")

One way to make up the function I'm missing, could be like this:

(de sindex (Frag Src)
   (if (match (make (link '@A) (mapcar link (chop Frag)) (link '@B)) (chop Src))
      (length @A) ) )

Then (sindex "Li" "PicoLisp") would give 4. Maybe it would be preferable for it 
to give 5.
As it is quite common for PicoLisp functions to have different behaviours 
depending on the type of input, the behaviour of my 'sindex' could also be made 
a part of the standard PicoLisp 'index' function.

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

Reply via email to