I'm interested in J solutions of an application of Haskell's monadic
mapping:

mapM (\x -> [x-1, x+1]) [10,20,30]

[[9,19,29],[9,19,31],[9,21,29],[9,21,31],
 [11,19,29],[11,19,31],[11,21,29],[11,21,31]

Here's my first shot:

((-"1) _1^#:@i.@(2^#)) 10 20 30

Or in case of 3 functions:

([`(>:@[)`(<:@[)@.]"0"(1) 3 #.^:_1 i.@(3^#)) 10 20 30

The number of elements of the result is equal to the <number of
functions>^<list length>


=@@i



----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to