| data,None -> data, Some(Repeat R (n-1)) Let rec Repeat (Runner(r) as R) n = Runner(fun x -> | data,Some(next) -> data, Some(Pair(next,R2))) Let rec Pair(Runner(r1),R2) = Runner(fun x -> type Runner = Runner of (int -> int * option) am still trying to see if there's a good way to work in a "list", since the results seem isomorphic to cons cells. Here's another way that's a little more refined. | Result(data,Some(next)) -> Result(data, Some(Pair(next, Repeat r (n-1)))) | Result(data,None) -> Result(data, Some(Repeat r (n-1))) | Result(data,Some(next)) -> Result(data,Some(Pair(next,r2))) | Result(data,None) -> Result(data, Some(r2)) That said, I think there may be a better/simpler representation choice, I'm still mulling it over. Here's something that's almost a direct translation of the same solution strategy. Return new Result(res.Data, new Sequence(_runner)) New Pair(res.Next, new Sequence(_runner))) Return new Result(res.Data, new Repeat(_toRun, _counter - 1)) Public Repeat(IRunner toRun, int counter) Return new Result(res.Data, new Pair(res.Next, _two)) I'm open to any sort of creative solutions :) interface IRunner I have a feeling the matching F# code will be significantly smaller. The C# code is posted below, and I would like some help porting it to F#. I wrote some C# code to conceptualize it, but I'm having trouble porting it to F#. I'm trying to write a small little scripting engine for a bullet hell game and I would like to do it in F#.
0 Comments
Leave a Reply. |