1 people like it.

hof.fsx

Higher order function

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
11: 
12: 
13: 
14: 
15: 
16: 
17: 
18: 
19: 
20: 
let rafael func =
    func "domain\\\
afael.rocha"
    
let upload user file =
    printf "%s uploaded the file %s\
\
" user file
    
let files = ["lorem.docx"; "ipsum.pdf"; "dolor.xls"; "amet.pptx"]

let bulkupload user (fileCollection : List<string>) =
    for file in fileCollection do
        upload user file

let firstFileIn (list:List<string>) =
    list.Head

rafael upload (firstFileIn files)
rafael bulkupload files
val rafael : func:(string -> 'a) -> 'a

Full name: Script.rafael
val func : (string -> 'a)
val user : 'a
val file : 'b
val printf : format:Printf.TextWriterFormat<'T> -> 'T

Full name: Microsoft.FSharp.Core.ExtraTopLevelOperators.printf
Multiple items
module List

from Microsoft.FSharp.Collections

--------------------
type List<'T> =
  | ( [] )
  | ( :: ) of Head: 'T * Tail: 'T list
  interface IEnumerable
  interface IEnumerable<'T>
  member Head : 'T
  member IsEmpty : bool
  member Item : index:int -> 'T with get
  member Length : int
  member Tail : 'T list
  static member Cons : head:'T * tail:'T list -> 'T list
  static member Empty : 'T list

Full name: Microsoft.FSharp.Collections.List<_>
Multiple items
val string : value:'T -> string

Full name: Microsoft.FSharp.Core.Operators.string

--------------------
type string = System.String

Full name: Microsoft.FSharp.Core.string
val upload : ('a -> 'b -> unit)
type 'T list = List<'T>

Full name: Microsoft.FSharp.Collections.list<_>
Next Version Raw view Test code New version

More information

Link:http://fssnip.net/hH
Posted:11 years ago
Author:Rafael
Tags: hof , tryfsharp