map trim command on list members

Q&A's, tips, howto's
Post Reply
vetelko
Posts: 21
Joined: Thu Oct 13, 2016 4:47 pm

map trim command on list members

Post by vetelko »

Hi guys,

how can I map trim command to list members?
say I have list like this:

Code: Select all

(set 'lst '("a." "b " "c"))
and I want to trim dot character trying this construct:

Code: Select all

(set 'lst2 (map (curry trim {.}) lst))
but it doesn't work, output is:

Code: Select all

("." "." ".")
newLISP v.10.7.4 64-bit on OpenBSD IPv4/6 UTF-8 libffi

ralph.ronnquist
Posts: 216
Joined: Mon Jun 02, 2014 1:40 am
Location: Melbourne, Australia

Re: map trim command on list members

Post by ralph.ronnquist »

If you try it out by hand, as in

Code: Select all

> (curry trim ".")
(lambda ($x) (trim "." $x))
you see that the curried function is not exactly what you want.
You rather need to use a function like

Code: Select all

(fn ($x) (trim $x "."))
instead; there's no abbreviation macro for that order of arguments.

Post Reply