The only cute ways I can think of are

let arr = [|1;2|]

let way1 = arr |> function [|a;b|] -> (a,b)

let way2 = arr |> fun a -> a.[0], a.[1]

By on 8/20/2009 8:50 AM ()

Ok, thanks!

By on 8/20/2009 9:02 AM ()

A similar problem:

How to apply 2 functions to the same seq.

assume you have s=seq<float>, is there some op that works as follows:

s |> op (Seq.min,Seq.max) ,

would yield same as

Seq.min s, Seq.max s

Thanks a lot

By on 8/21/2009 1:54 PM ()

(web coding, have not compiled)

let op (f,g) x = f x, g x

seems to do it.

Of course this traverses the sequence twice in your example; you'd need f and g to both be folds in order to be able to combine both operations into a single sequence traversal.

By on 8/21/2009 3:11 PM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper