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' and
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).
That does the trick. Thank you Alex!
I think Haskell makes a big deal about Pattern Matching. 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!
Happy 2017.
On Tue, Jan 03, 2017 at 10:21:38AM +0100,
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. N
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 constant.
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:
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 match
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 prob