Page 1 of 1

map trim command on list members

Posted: Wed Oct 19, 2016 9:46 am
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

("." "." ".")

Re: map trim command on list members

Posted: Wed Oct 19, 2016 10:43 am
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.