Re: [racket-users] Official Docker images for Racket
Am 03.09.2015 um 07:19 schrieb Rickard Andersson: > I've previously tried to minimize the build without any success, so if > you can make a base image using only busybox or alpine linux without any > problems that'd obviously be preferable. I would welcome that as well. I was doing some experiments on my local machine to get a good Dockerfile but up to now I am not satisfied with the results. Best wishes, Daniel > > On Wed, 2 Sep 2015, Asumu Takikawa wrote: > >> On 2015-09-02 15:35:25 -0700, Jack Firth wrote: >>> I do a lot of Racket development in Docker, and it's a pretty big pain. >>> There's a handful of images on Docker Hub but they're pretty >>> unmaintained, >>> usually lag behind a version or two, tend to be built off an >>> unnecessarily >>> large base image like ubuntu, don't offer a snapshot build, and don't >>> offer >>> "minimal Racket" versions. I'd like to work on this and add some Racket >>> images to the Official images like other languages have. Has anyone else >>> worked on this? >> >> That sounds great and if you put Racket images up I would happily use >> them. >> >> I did look into building images on Dockerhub a while ago and had trouble >> getting builds to finish (ran out of memory), but it looks like they have >> improved the infrastructure since then. >> >> Cheers, >> Asumu >> >> -- >> You received this message because you are subscribed to the Google >> Groups "Racket Users" group. >> To unsubscribe from this group and stop receiving emails from it, send >> an email to racket-users+unsubscr...@googlegroups.com. >> For more options, visit https://groups.google.com/d/optout. >> > -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] Re: Official Docker images for Racket
Am 03.09.2015 um 08:07 schrieb Jack Firth: > I've attempted to compile from source in an alpine image, but with no > success. There's a bit too much arcane magic there for me to figure out how > to do that. > Perhaps you could provide your Dockerfile etc. on Github so others could look into it and maybe give some hints. Daniel -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] More Racket Place abuse^H^H^H^H^H issues
On 28/08/15 20:02, Matthew Flatt wrote: > I think the sandbox is relevant because `sandbox-memory-limit` remains > in effect (even though you're disabling the per-evaluation limit by > setting `sandbox-eval-limits`). A sandbox memory limit triggers memory > accounting in the GC. I see that memory accounting in the GC has a > problem with places, and I can provoke a crash by targeting that > problem directly. Out of interest - is there much overhead in having memory accounting active in the GC? I can’t avoid it, since I’ll be using sandboxes... but is there any idea of the cost? Tim -- Tim Brown CEng MBCS City Computing Limited · www.cityc.co.uk City House · Sutton Park Rd · Sutton · Surrey · SM1 2AE · GB T:+44 20 8770 2110 · F:+44 20 8770 2130 City Computing Limited registered in London No:1767817. Registered Office: City House, Sutton Park Road, Sutton, Surrey, SM1 2AE VAT No: GB 918 4680 96 -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] Lost in ellipsis depths
Jens Axel Søgaard writes: > Here are two variations: ... Alexander D. Knauth writes: > To make it look a little less messy, here's what I would do for stuff like > this: ... Matthias Felleisen writes: > I think you want either this: ... Ryan Culpepper writes: > Here's one more solution, using "template metafunctions" (inspired by > Redex's metafunctions). And yes, most of the point of template > metafunctions is to have something that cooperates with ellipses like > you want. Thanks to all of you for your suggestions! For my current ten-line macro, I'll go with stx-map, but I really like Ryan's template metafunctions for more complex situations, which I expect to run into quite soon. Konrad. -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] More Racket Place abuse^H^H^H^H^H issues
At Thu, 3 Sep 2015 11:12:50 +0100, Tim Brown wrote: > On 28/08/15 20:02, Matthew Flatt wrote: > > I think the sandbox is relevant because `sandbox-memory-limit` remains > > in effect (even though you're disabling the per-evaluation limit by > > setting `sandbox-eval-limits`). A sandbox memory limit triggers memory > > accounting in the GC. I see that memory accounting in the GC has a > > problem with places, and I can provoke a crash by targeting that > > problem directly. > > Out of interest - is there much overhead in having memory accounting > active in the GC? > > I can’t avoid it, since I’ll be using sandboxes... > but is there any idea of the cost? Memory accounting increases the cost of a major GC by about 25%. -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[racket-users] help on coding finite state automata
Dear All, I'm a complete newbie in racket and need help in coding finite state machine/automata. Please pardon any of my ignorance. Thanks to this post of Tim Thornton, I see a very good way to code FSM: http://timthornton.net/blog/id/538fa6f2f09a16ba0674813d I'd summarise it as following: A finite state automaton has a number of states and each state has a name plus many transition rules. He structures it in racket as following: (struct automaton (current-state states)) (struct state (name actions)) (struct action (event result)) A simple automaton can be like this: (define simple-fsm (fsm 'A (list (fstate 'A (list (action 0 'A) (action 1 'B))) (fstate 'B (list (action 0 'B) (action 1 'A)) The automaton is in state A which has 2 transition rules: - if event 1 happens, the automaton jumps to state B, - if event 0 happens, it stays in state A. Then he writes some functions to update the automaton after each event (in the post). Plus this function he omits (I guess): (define fsm-update-state old-fsm new-state) (struct-copy automaton old-fsm [current-state new-state])) HERE IS THE QUESTION: Using this way, after each event, there'd be a NEW automaton created. So I'm worried about scaling. I'd like to generate 100 automata. In each cycle, I'd pair the automata to interact for 50 times. Which means that there'd be 100 new automata created for every single cycle. And I'd like to run at least 1000 cycles. Would there be any problem with scaling? If yes, is there a way around this? Any kind of comments and suggestions are welcomed and appreciated, Thank you really much, Chi -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] help on coding finite state automata
On 03/09/2015 16:29, Linh Chi Nguyen wrote: Dear All, I'm a complete newbie in racket and need help in coding finite state machine/automata. Please pardon any of my ignorance. Thanks to this post of Tim Thornton, I see a very good way to code FSM: http://timthornton.net/blog/id/538fa6f2f09a16ba0674813d Looks interesting! When I first heard of finite state machines they were presented to me as an abstract model of computers in general. AFAIR finite state automatons are used to teach how to realize really fast orthography checks but for me these were more connected to the concept of directed cyclic graphs. HERE IS THE QUESTION: Using this way, after each event, there'd be a NEW automaton created. That's because of pure functional programming as the post states. So I'm worried about scaling. I'd like to generate 100 automata. In each cycle, I'd pair the automata to interact for 50 times. Which means that there'd be 100 new automata created for every single cycle. And I'd like to run at least 1000 cycles. Would there be any problem with scaling? If yes, is there a way around this? With the knowledge of a regular computer already being such an automaton (in some way) I have learned to appreciate the /case/ form for data driven programming. Especially if one doesn't care about past states (which will need memory one way or the other) it's probably better to describe the automaton "from inside" and see the whole program (or some part of it) as an automaton. For event driven programs nowadays (at least in Racket) we only need to define the actions as regular procedures or callbacks. -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] help on coding finite state automata
If your FSM are defined at compile-time, you can write a macro (in `syntax-rules` or `syntax-case`) that transforms FSMs defined in your FSM macro language to efficient Racket code. Even with a macro, there are a few popular ways to do it, but I suggest trying to make your state transitions be Racket tail calls. Neil V. -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] help on coding finite state automata
On 03/09/2015 16:34, Neil Van Dyke wrote: If your FSM are defined at compile-time, you can write a macro (in `syntax-rules` or `syntax-case`) that transforms FSMs defined in your FSM macro language to efficient Racket code. Even with a macro, there are a few popular ways to do it, but I suggest trying to make your state transitions be Racket tail calls. Which reminds me of Shriram's awesome paper: http://cs.brown.edu/~sk/Publications/Papers/Published/sk-automata-macros/ Enjoy! -- Paulo Matos -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[racket-users] Re: Futures vs. Places for parallelizing a simple game engine
On Monday, August 31, 2015 at 1:27:42 PM UTC-4, Brian Adkins wrote: > I'm writing a Reversi/Othello game engine in Racket as a learning exercise. > Since my macbook pro has 4 cores and 8 hardware threads, I'd like to see what > sort of speedup I can get by parallelizing it. > > I read through chapter 20 of the Racket Guide, and I *think* places may be > more suitable than futures for this task due to the fact that each compute > unit will be allocating memory for the next set of moves, etc. > > Does that sound right? No opinions on this? For you experienced Racketeers, which approach would you choose for maximum speed? -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] Re: Futures vs. Places for parallelizing a simple game engine
Hi Brian, For this task places will be the perfect choice. Two reasons: i) each place can work a on its own board (and there is no need for shared data) [at least if you are not using transposition tables] ii) the amount of data needed to start a task from a given board is only a few bytes, so the communication overhead is small For most boards you can do this: for a board B and a player P to move: generate all boards B1, B2, ... resulting from player P making one move on board B place the boards in a job queue when a place signals it is ready, send a board to the place In some situations there are very few moves available for P. In that case you will need to generate boards resulting from two (or more) moves before placing them in the job queue. /Jens Axel 2015-09-03 18:04 GMT+02:00 Brian Adkins : > On Monday, August 31, 2015 at 1:27:42 PM UTC-4, Brian Adkins wrote: > > I'm writing a Reversi/Othello game engine in Racket as a learning > exercise. Since my macbook pro has 4 cores and 8 hardware threads, I'd like > to see what sort of speedup I can get by parallelizing it. > > > > I read through chapter 20 of the Racket Guide, and I *think* places may > be more suitable than futures for this task due to the fact that each > compute unit will be allocating memory for the next set of moves, etc. > > > > Does that sound right? > > No opinions on this? For you experienced Racketeers, which approach would > you choose for maximum speed? > > -- > You received this message because you are subscribed to the Google Groups > "Racket Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to racket-users+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- -- Jens Axel Søgaard -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[racket-users] Macro-generating macros
Hi everyone, Here's another plea for help from the macro experts. I am trying to write a macro whose expansion contains another macro, more precisely a let-syntax form. My full example is attached below. In the first part, I use a let-syntax directly. In the second part, I use a macro that generates exactly the form that I wrote by hand in the first part - but then the let-syntax seems to be ignored. The macro stepper isn't of much help here. It shows the expansion of (defn (foo2 ...)) into essentially what I wrote by hand for foo1, and then declares the expansion finished. Can anyone tell me (1) why this doesn't work and (2) how to fix it? Thanks in advance, Konrad. == #lang racket (require syntax/parse) (require (for-syntax syntax/parse)) ; ; this works fine ; (define (foo1 x y) (let-syntax ([send (λ (stx) (syntax-parse stx ((send obj:expr method:id x:expr ...) #'(method obj x ...]) (send x + y))) (foo1 2 3) ; ; this doesn't ; (define-syntax (def stx) (syntax-parse stx [(_ (fn-name:id arg:id ...) body ... ) #'(define (fn-name arg ...) (let-syntax ([send (λ (stx) (syntax-parse stx [(send obj:expr method:id x:expr (... ...)) #'(method obj x (... ...))]))]) body ...))])) (def (foo2 x y) (send x + y)) (foo2 2 3) ;; send: target is not an object ;; ; target: 2 ;; ; method name: + ;; ; -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] Re: Futures vs. Places for parallelizing a simple game engine
On Thursday, September 3, 2015 at 12:27:01 PM UTC-4, Jens Axel Søgaard wrote: > [...] > > For this task places will be the perfect choice. > > [...] Great - thanks for the advice. I'll create a non-parallel version first as a baseline, and then a version with places. Once I have some code to share, I'll post back here with a github repo. -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] Macro-generating macros
On Sep 3, 2015, at 11:44, Konrad Hinsen wrote: > Hi everyone, > > Here's another plea for help from the macro experts. I am trying to > write a macro whose expansion contains another macro, more precisely a > let-syntax form. My full example is attached below. In the first part, > I use a let-syntax directly. In the second part, I use a macro that > generates exactly the form that I wrote by hand in the first part - > but then the let-syntax seems to be ignored. > > The macro stepper isn't of much help here. It shows the expansion > of (defn (foo2 ...)) into essentially what I wrote by hand for foo1, > and then declares the expansion finished. > > Can anyone tell me (1) why this doesn't work and (2) how to fix it? It's a capture problem. In the first case, you're just binding the name "send" locally and all is well. In the second case, you're trying to introduce a binding for "send" that you didn't get from the input form. You're also getting a confusing error because "send" is already bound; try using a name that's not already defined and you should get an unbound identifier. You can fix this in one of two ways. Your `def' macro could take the name of the `send' macro it binds as a parameter, which gets a little ugly. Alternatively, you can use a syntax parameter, which is probably the ideal solution here. (require (for-syntax syntax/parse)) (require racket/stxparam) (define-syntax-parameter send (lambda (stx) (raise-syntax-error 'send "send used out of context"))) (define-syntax (def stx) (syntax-parse stx [(_ (fn-name:id arg:id ...) body ... ) #'(define (fn-name arg ...) (syntax-parameterize ([send (λ (stx) (syntax-parse stx [(send obj:expr method:id x:expr (... ...)) #'(method obj x (... ...))]))]) body ...))])) (def (foo2 x y) (send x + y)) (foo2 2 3) -- Brian Mastenbrook br...@mastenbrook.net http://brian.mastenbrook.net/ -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[racket-users] Re: help on coding finite state automata
On Thursday, September 3, 2015 at 10:29:33 AM UTC-4, Linh Chi Nguyen wrote: > Dear All, > I'm a complete newbie in racket and need help in coding finite state > machine/automata. Please pardon any of my ignorance. > > Thanks to this post of Tim Thornton, I see a very good way to code FSM: > http://timthornton.net/blog/id/538fa6f2f09a16ba0674813d > > I'd summarise it as following: > A finite state automaton has a number of states and each state has a name > plus many transition rules. He structures it in racket as following: > > (struct automaton (current-state states)) > (struct state (name actions)) > (struct action (event result)) > > A simple automaton can be like this: > (define simple-fsm (fsm 'A > (list (fstate 'A (list (action 0 'A) >(action 1 'B))) > (fstate 'B (list (action 0 'B) >(action 1 'A)) > > The automaton is in state A which has 2 transition rules: > - if event 1 happens, the automaton jumps to state B, > - if event 0 happens, it stays in state A. > > Then he writes some functions to update the automaton after each event (in > the post). Plus this function he omits (I guess): > (define fsm-update-state old-fsm new-state) > (struct-copy automaton old-fsm [current-state new-state])) > > HERE IS THE QUESTION: > > Using this way, after each event, there'd be a NEW automaton created. So I'm > worried about scaling. I'd like to generate 100 automata. In each cycle, I'd > pair the automata to interact for 50 times. Which means that there'd be 100 > new automata created for every single cycle. And I'd like to run at least > 1000 cycles. > > Would there be any problem with scaling? If yes, is there a way around this? > > Any kind of comments and suggestions are welcomed and appreciated, > Thank you really much, > Chi You might want to take a look at https://github.com/mromyers/automata specifically, https://github.com/mromyers/automata/blob/master/examples.rkt and https://github.com/mromyers/automata/blob/master/machines.rkt I more or less just use the definition that was in my textbook: you provide a transition function, and the DFA or NFA just uses stream-fold to get the extended transition. I used a bunch of generics stuff to try to generalize everything past the point of practicality, but it's still reasonably fast. It's not documented, but use (in-machine? M seq) to check for acceptance, (extended-transition M start seq) for final state(s). There's also a minimization function and nfa->dfa conversion in there, but they might have some bugs. -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] Re: Official Docker images for Racket
> Perhaps you could provide your Dockerfile etc. on Github so others could > look into it and maybe give some hints. I've got them up at https://github.com/jackfirth/racket-docker, and they're on Docker Hub as https://hub.docker.com/r/jackfirth/racket/. Currently the images are built off Debian and support all racket versions back to 5.3 (except 5.9x variants because I couldn't find debian installers for them). So now you should be able to do this: $ docker run -it jackfirth/racket Welcome to Racket v6.2.1. > And this: $ docker run -it jackfirth/racket:5.3 Welcome to Racket v5.3. > Next steps are minimal racket images built on something like Alpine Linux. I'll throw up my experiments on there, but I haven't gotten anything working yet. -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] Re: Official Docker images for Racket
This a fantastic! Thank you for the access to old versions of Racket. Robby On Thu, Sep 3, 2015 at 6:29 PM, Jack Firth wrote: >> Perhaps you could provide your Dockerfile etc. on Github so others could >> look into it and maybe give some hints. > > I've got them up at https://github.com/jackfirth/racket-docker, and they're > on Docker Hub as https://hub.docker.com/r/jackfirth/racket/. Currently the > images are built off Debian and support all racket versions back to 5.3 > (except 5.9x variants because I couldn't find debian installers for them). So > now you should be able to do this: > > $ docker run -it jackfirth/racket > Welcome to Racket v6.2.1. >> > > And this: > > $ docker run -it jackfirth/racket:5.3 > Welcome to Racket v5.3. >> > > Next steps are minimal racket images built on something like Alpine Linux. > I'll throw up my experiments on there, but I haven't gotten anything working > yet. > > -- > You received this message because you are subscribed to the Google Groups > "Racket Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to racket-users+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] Re: help on coding finite state automata
Wow as much as i appreciate and try to see through all the answers, i have to confess that i'm a first year Phd student in economics. So writing macro is too far for me now. I'd just process with struct.. And see how expensive it is for my agent based model. Hopefully i can show you the code some day, regarding all these suggestions, if still relevant. Thank you, Chi On 04/set/2015, at 03:25, mrmyers.random.suf...@gmail.com wrote: > On Thursday, September 3, 2015 at 10:29:33 AM UTC-4, Linh Chi Nguyen wrote: >> Dear All, >> I'm a complete newbie in racket and need help in coding finite state >> machine/automata. Please pardon any of my ignorance. >> >> Thanks to this post of Tim Thornton, I see a very good way to code FSM: >> http://timthornton.net/blog/id/538fa6f2f09a16ba0674813d >> >> I'd summarise it as following: >> A finite state automaton has a number of states and each state has a name >> plus many transition rules. He structures it in racket as following: >> >> (struct automaton (current-state states)) >> (struct state (name actions)) >> (struct action (event result)) >> >> A simple automaton can be like this: >> (define simple-fsm (fsm 'A >>(list (fstate 'A (list (action 0 'A) >> (action 1 'B))) >> (fstate 'B (list (action 0 'B) >> (action 1 'A)) >> >> The automaton is in state A which has 2 transition rules: >> - if event 1 happens, the automaton jumps to state B, >> - if event 0 happens, it stays in state A. >> >> Then he writes some functions to update the automaton after each event (in >> the post). Plus this function he omits (I guess): >> (define fsm-update-state old-fsm new-state) >> (struct-copy automaton old-fsm [current-state new-state])) >> >> HERE IS THE QUESTION: >> >> Using this way, after each event, there'd be a NEW automaton created. So I'm >> worried about scaling. I'd like to generate 100 automata. In each cycle, I'd >> pair the automata to interact for 50 times. Which means that there'd be 100 >> new automata created for every single cycle. And I'd like to run at least >> 1000 cycles. >> >> Would there be any problem with scaling? If yes, is there a way around this? >> >> Any kind of comments and suggestions are welcomed and appreciated, >> Thank you really much, >> Chi > > You might want to take a look at https://github.com/mromyers/automata > specifically, https://github.com/mromyers/automata/blob/master/examples.rkt > and https://github.com/mromyers/automata/blob/master/machines.rkt > I more or less just use the definition that was in my textbook: you provide a > transition function, and the DFA or NFA just uses stream-fold to get the > extended transition. I used a bunch of generics stuff to try to generalize > everything past the point of practicality, but it's still reasonably fast. > It's not documented, but use (in-machine? M seq) to check for acceptance, > (extended-transition M start seq) for final state(s). > > There's also a minimization function and nfa->dfa conversion in there, but > they might have some bugs. > > -- > You received this message because you are subscribed to a topic in the Google > Groups "Racket Users" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/racket-users/4o1goSwrLHA/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > racket-users+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [racket-users] Re: help on coding finite state automata
On Friday, September 4, 2015 at 1:34:38 AM UTC-4, Linh Chi Nguyen wrote: > Wow as much as i appreciate and try to see through all the answers, i have to > confess that i'm a first year Phd student in economics. So writing macro is > too far for me now. > > I'd just process with struct.. And see how expensive it is for my agent based > model. Hopefully i can show you the code some day, regarding all these > suggestions, if still relevant. > > Thank you, > Chi > > On 04/set/2015, at 03:25, mrmyers.random.suf...@gmail.com wrote: > > > On Thursday, September 3, 2015 at 10:29:33 AM UTC-4, Linh Chi Nguyen wrote: > >> Dear All, > >> I'm a complete newbie in racket and need help in coding finite state > >> machine/automata. Please pardon any of my ignorance. Hi Linh. One problem with doing things that way is that it creates a lot of temporary things that need to be cleaned up. The nice thing about a finite-state-machine is that you only need to keep track of one thing (current state) while it runs. In the code I linked above, a finite state machine (I use "dfa" or "deterministic finite automata") is defined as something with a 'transition function' δ(p,a) = q which, given a state p and symbol a, returns a new state q. It also has to have an initial state, and an accept? function to determine which states are to be accepted. I also wrote some helpful macros to make defining one a lot easier. You can write (define M (dfa (alphabet: '(a b)) (table: [sa : x sb] [sb : sa x] [x : x x]) (start: sa) (accept: sb))) (in-machine? M '(a b a b a b)) to accept only lists that contain alternating seqences of 'a followed by 'b. If you make your alphabet a string or list of characters, it can scan strings or lists of characters for acceptance instead. If the alphabet had been "ab", everything else could be kept the same, but you could write (in-machine? M "ababab") You can use symbols, numbers, or whatever you'd like to represent states, just list the transitions for each state in the order of the alphabet you supplied. Lastly, if you're not just interested in whether it accepts or not, and want to know the final state, use (extended-transition M s1 '(a b a b a b)) -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.