Hello!
I've an array:
{ "abc" "def" "cba" "fed" "junk" }
I'd like to filter this array by whether the reverse of an element is also
a member.
In Python, I'd express this as:
>>> array = ["abc", "def", "cba", "fed", "junk"]
>>> [item for item in array if item[::-1] in array] # [::-1] reverses a
string
And the result of the list comprehension would be
['abc', 'def', 'cba', 'fed']
A more functional example would be, e.g:
list(filter(lambda x: x[::-1] in array, array))
For the same result.
How can I do the same thing in Factor? I've tried:
dup [ dup reverse swap member? ] filter
which gives an empty array because the quotation fails for each item.
Regards, cat.
------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785351&iu=/4140
_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk