You might be interested by this manual section: [link:research.microsoft.com]

Your example worked in OCaml, but recursion need to be delayed in F#. One solution is:

1
2
3
4
5
6
7
type node =
    { Name: string;
      Nb: (node list) lazy}

let rec (A:node) = {Name="A"; Nb=lazy [B;C]}
and (B:node) = {Name="B"; Nb=lazy [A;C]}
and (C:node) = {Name="C"; Nb=lazy [A;B]}

And then, to get neighbours: Lazy.force A.Nb or A.Nb.Force

I don't know if we can get something prettier.

Laurent.

By on 3/5/2007 1:10 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