Re: matching a simple string variable

2017-01-03 Thread Alexander Burger
Hi Joe, > > (match (cons '@A (conc (chop Varstring) '(@B))) ... > I'm using your "match" here as a simple string matcher. I'm sure there are > better ways, but I'm happy with my baby steps that appear to work! If you are only interested in a boolean result, but don't need the values of '@A'

Re: matching a simple string variable

2017-01-03 Thread Erik Gustafson
Hi Joe, Also note that it's fairly easy to pull in regex functionality, should you need it. See http://rosettacode.org/wiki/Regular_expressions#PicoLisp for an example (pil64).

Re: matching a simple string variable

2017-01-03 Thread Alexander Burger
On Tue, Jan 03, 2017 at 07:52:34AM +0100, Alexander Burger wrote: >(match (append '(@A) (chop Varstring) '(@B)) ... BTW, better is perhaps (match (cons '@A (conc (chop Varstring) '(@B))) ... because 'append' unnecessarily copies the list just built by 'chop'. 'conc' avoids that garbage.

Re: matching a simple string variable

2017-01-02 Thread Alexander Burger
Hi Bruno, > If you want > (match '(@A (chop varstring) @B) description) > to match > (match '(@A "C" "I" "T" "Y" @B) description) > you'll have to add a tilde before chop, like this: > (match '(@A ~(chop varstring) @B) description) Yes, but this only works if the value of 'varstring' is

Re: matching a simple string variable

2017-01-02 Thread Alexander Burger
Hi Joe, > (setq varstring "CITY") > (match '(@A (chop varstring) @B) description) > > perhaps the function in the middle of the quote is the problem? Or the extra > list introduced by chop? Yes. The 'chop' call is not evaluated inside the quoted expression. There are two ways to handle it:

Re: matching a simple string variable

2017-01-02 Thread Bruno Franco
I think you're right on what's the problem. Chopping the varstring creates a list of characters, ("C" "I" "T" "Y"), and the final list would look like '(@A ("C" "I" "T" "Y") @B), which does not match '(@A "C" "I" "T" "Y" @B) above. If you want (match '(@A (chop varstring) @B) description) to

matching a simple string variable

2017-01-02 Thread Joe Golden
I'm trying to do some simple string matching and find match works nicely when the string is a literal list of chars like (match '(@A "C" "I" "T" "Y" @B) description) but I need to match on a variable string stored in varstring which then needs to get chopped (I think). I'm running into