Created
May 14, 2015 18:38
-
-
Save SteveGilham/a5f0ec2c7de7764fcfb9 to your computer and use it in GitHub Desktop.
Function serialization example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System | |
open System.IO | |
open System.Runtime.Serialization.Formatters.Soap | |
open System.Text | |
let mhead(m : list<Object>) : list<Object> = [m.Head] | |
let addN n = | |
(fun x -> x + n) | |
let add2 = addN 2 | |
let emitString x = | |
let sf = new SoapFormatter() | |
let sink = new MemoryStream() | |
sf.Serialize(sink, x) | |
printfn "%s" <| x.GetType().FullName | |
printfn "%s" <| Encoding.Default.GetString(sink.ToArray()) | |
[ mhead :> obj; addN :> obj; add2 :> obj; emitString :> obj] | |
|> Seq.iter emitString | |
printfn "-------------------" | |
[ mhead :> obj; addN :> obj; add2 :> obj; emitString :> obj] | |
|> Seq.iter emitString; | |
;; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment