User loginNavigation |
Un-filter (or merge) listsWhat is the standard functional construct which is the converse of filter? Eg. if I want to add 0 between all elements of a list? Or if I want to merge two sorted lists preserving sorting? I am thinking of a "unfilter" construct which takes a list of lists, and a list of functions applied in turn (*insert 0 between two elements of the list*) unfilter [a] [fun x::xs -> (x, [xs]); fun as -> (0, [as])] (*merge two sorted lists*) unfilter [a;b] [fun as, bs -> match as, bs with | x::xs, y::ys => if y < x then (y, [as;ys]) else (x, [xs;bs]) | [], y::ys => (y, [[];ys]) | x::xs, [] => (x, [xs;[]])] By Denis Bredelet -jido at 2008-04-22 11:25 | LtU Forum | previous forum topic | next forum topic | other blogs | 5965 reads
|
Browse archives
Active forum topics |
Recent comments
22 weeks 6 days ago
22 weeks 6 days ago
22 weeks 6 days ago
45 weeks 19 hours ago
49 weeks 2 days ago
50 weeks 6 days ago
50 weeks 6 days ago
1 year 1 week ago
1 year 6 weeks ago
1 year 6 weeks ago