Re: Missing function for locating string fragment?

2014-09-15 Thread Jon Kleiser
Hi Alex, On 12. Sep, 2014, at 16:06, Alexander Burger a...@software-lab.de wrote: It is not a good idea to build a list only to count its length. Better count in a loop directly, e.g.: (de sindex (Frag Src) (for ((I . L) (chop Src) L (cdr L)) (T (pre? Frag L) I) ) ) For

Re: Missing function for locating string fragment?

2014-09-15 Thread Alexander Burger
Hi Jon, For this 'sindex' I think it would be good to first test if Frag is NIL, since with your version above (sindex NIL foo) would give 1. The 1 is (arguably) correct, because an empty string is a substring of *every* string. : (pre? NIL bla) - bla ♪♫ Alex -- UNSUBSCRIBE:

Missing function for locating string fragment?

2014-09-12 Thread Jon Kleiser
Hi, 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

Re: Missing function for locating string fragment?

2014-09-12 Thread Alexander Burger
Hi Jon, 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? Yes, that's right. In fact, the only functions which I would regard as string manipulations (i.e. operate directly on a

Re: Missing function for locating string fragment?

2014-09-12 Thread Jon Kleiser
Hi Alex, Thanks for the reply, and for suggesting a better solution than the one I made up. I have no immediate use for such a 'sindex' function, and maybe this is not a function that one would need very often when doing things the PicoLisp way. Have a nice weekend! /Jon On 12. sep. 2014, at