Timeline for Elegant way to map a function to only the last element of each sublist
Current License: CC BY-SA 3.0
3 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jul 7, 2012 at 20:31 | comment | added | b.gates.you.know.what |
@Andrew For the second version you want to apply Flatten only to the first argument as in {Flatten[Most[#]], Thread[g[Last[#]]]} & /@ test ; This will give the same result you mention.
|
|
Jul 7, 2012 at 20:20 | comment | added | Andrew |
Thanks. I think this needs Flatten[#, 1]& around it to be correct. That is, Flatten[{Most[#], Thread[g[Last[#]]]} & /@ test, 1] . I think. Am I correct?
|
|
Jul 7, 2012 at 18:06 | history | answered | b.gates.you.know.what | CC BY-SA 3.0 |