

IRUNNER GAME BLUETOOTH

By adding the outer sequence it allows the inner sequence to fully control it's lifetime. This example is a little contrived but you could think of the program as a sequence of sequences, the "action queue" that Brian was hinting at. You may consider using the built-in sequence support in F# (along with the very nice sequence expressions). New Result(res.Data, new Sequence(runner)) New Result(res.Data, new Pair(res.Next, new Sequence(runner))) New Result(res.Data, new Repeat(toRun, counter - 1)) New Result(res.Data, new Pair(res.Next, new Repeat(toRun, counter - 1))) Type Repeat(toRun:IRunner, counter:int) = New Result(res.Data, new Pair(res.Next, two)) Member this.Run(data) = new Result(data, null) Member this.Run(data) = new Result(data+1, null) I am assuming that IRunner and Result are predefined, since if not you should redesign the system to be more focused on FP concepts without all this inheritance.Īnyway, here is a binary (I believe) counterpoint to the given example type AddOne = It would be interesting to know how this will be used/consumed, as perhaps a small change there might allow for a completely different strategy. But each guy can produce some 'suffix actions' that run immediately after him (but before the remaining work in the would-be queue), and trying to maintain the ordering with a purely functional data structure is potentially inefficient (without the right tree/queue library at hand).

It's almost just like an 'Action queue', a list of int->int functions. | data,xs -> data, xs List.init (n-1) (fun _ -> R)) // inefficient type Runner = Runner of (int -> int * list) One more version, it uses lists, but now I've a feeling for what's weird here. | data,Some(next) -> data, Some(Pair(next, Repeat R (n-1)))) | 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
IRUNNER GAME CODE
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#.
