This is an easy example and can be explained in this sample:

1
let someList = List.map (fun x -> x * 12) [1;2;3]

To break this down consider:

  • "let someList =" - assign the binding someList
  • "List.map" - apply something to a list
  • "(fun x -> x * 12)" - the "something to apply". In this case, define a lambda that takes x and returns x * 12.
  • "[1;2;3]" - the list to use.

The result of the above code should be [12;24;36], i.e. someList should be

val it: int list = [12; 24; 36]

when run in fsi.

Regarding the second part of your question, can you provide a little more detail? There are a number of ways to approach this and I'd like to give you a concrete direction. If you have lisp code or something else, that would be useful as well.

By on 3/23/2006 7:27 AM ()

You'll have to pardon my F# syntax because I don't know how to write this but basically what I mean given what you have shown above would be:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//define some functions that spawn some processes like maybe they run animations in the background or something
let func1 -> spawnProcess1andReturnWithoutWaiting


let func2 -> spawnProcess2andReturnWithoutWaiting


let func3 -> spawnProcess3andReturnWithoutWaiting


let func4 -> spawnProcess4andReturnWithoutWaiting

//do a whole bunch of initialization stuff an now I'm ready to spawn those processes. I want to spawn these same processes multiple times in the code so rather than call them explicitly each time I want to define the "caller" function 

//now it's some function that takes a function as an argument and just calls that function

let caller = List.map (fun y -> y) [func1;func2;func3;func4]

so now I have done a bunch more stuff and I have checked something that lets me know all those spawned processes have completed and I want to spawn them again. I want to re-use "caller" how do I do that? Do I have to set something equal to it to get it to be re-evaluated or can I just put "caller" on a single line and it will be executed again?

By on 3/24/2006 8:58 AM ()
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