Flatten a 2d array

39 views
Skip to first unread message

foijord

unread,
Jan 27, 2012, 5:32:18 PM1/27/12
to F-Script
Hi,
what would be a nice way to flatten a 2d array in F-Script?

{{1, 2}, {2, 3}, {4, 5}} => {1, 2, 3, 4, 5}

Thanks,

Frode

Jeff Biggus

unread,
Jan 27, 2012, 5:45:22 PM1/27/12
to f-sc...@googlegroups.com
On Jan 27, 2012, at 4:32 PM, foijord wrote:

> what would be a nice way to flatten a 2d array in F-Script?
> {{1, 2}, {2, 3}, {4, 5}} => {1, 2, 3, 4, 5}


I think this is what you're looking for:

b := (a \#++) distinct
b at:(b sort)


Reply all
Reply to author
Forward
0 new messages