Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Help with F# understanding

Name: Anonymous 2008-05-07 21:51

fuck me im soo stoopid

Here is the function that is messing with me due to my inadequate understanding.


let generateTicket =
    let count = ref 0
    (fun () ->  count := !count + 1; !count)

Okay in the above code, the first thing that happens is that it declares a local element of state called count.  Then it returns a function value that refers to this state.  Every call it increments and dereferences this state.

No my question is how do I actually get at the dereferenced count (!count).

Logically I would think something like

printfn "%d" generateTicket

would work since it returns an Integer.  For some reason it says  incompatible type (unit -> int)

so of course if this is a function that takes nothing and creates an integer at least going

let x = generateTicket

should return an int since I don't use x() etc

but even when I do this I can't get at the derefenced count...

How the fuck do I get at it?

Name: Anonymous 2008-05-07 22:09

Sorry I understand my mistake I am fucking dumb

to execute the function and not just pass the function you add a () to it.

Name: Anonymous 2008-05-07 22:21

Sorry I understand you mistake you are fucking dumb

to save your dignity and not just flood the thread you add a (sage) to it.

Name: Anonymous 2008-05-08 7:19

You think people are going to help you just because you pretend to like their favorite toy language?

HAHAHAHAHAHAHAHAH

Name: Anonymous 2008-05-08 11:24

Please use code tags :(

Name: Anonymous 2008-05-08 11:38


╲ ╱
 ╳
╱ ╲

Name: Anonymous 2008-05-08 17:07

fuck me im soo stoopid

This is my pickup line.

Name: Sgt.Kabukiman笘赓 2012-05-23 5:24

All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy

Don't change these.
Name: Email:
Entire Thread Thread List