Re: [racket-users] help on coding finite state automata

2015-09-03 Thread Neil Van Dyke
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.


[racket-users] help on coding finite state automata

2015-09-03 Thread Linh Chi Nguyen
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

2015-09-03 Thread Michael Titke



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

2015-09-03 Thread Paulo Matos

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.


Re: [racket-users] Re: Futures vs. Places for parallelizing a simple game engine

2015-09-03 Thread Brian Adkins
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] Re: Futures vs. Places for parallelizing a simple game engine

2015-09-03 Thread Jens Axel Søgaard
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

2015-09-03 Thread Konrad Hinsen
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] Macro-generating macros

2015-09-03 Thread Brian Mastenbrook
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: Futures vs. Places for parallelizing a simple game engine

2015-09-03 Thread 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.


[racket-users] Re: help on coding finite state automata

2015-09-03 Thread mrmyers . random . suffix
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.


[racket-users] Re: Official Docker images for Racket

2015-09-03 Thread 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.

-- 
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] interface to unix sockets

2015-09-03 Thread Ryan Culpepper
I think someone was working on listener code for unix sockets a year or 
so ago, but I don't remember who or how far they got. Pull requests are 
welcome.


Ryan


On 8/31/15 2:36 PM, qwe-te...@yandex.ru wrote:

Racket provides unix-socket-connect and lacks listener. Is it going
to be added in future?


--
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

2015-09-03 Thread Ryan Culpepper
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.


> (require syntax/parse
   syntax/parse/experimental/template
   racket/syntax)
> (define-template-metafunction join
(syntax-parser
 [(_ a:id b:id)
  (format-id #'a "~a-~a" #'a #'b)]))
> (syntax-parse #'(foo a b c)
   [(f:id s:id ...)
(template (list (join f s) ...))])
#

Ryan


On 9/2/15 7:00 AM, Konrad Hinsen wrote:

Hi everyone,

I am working on what I consider a simple macro, but after reading all
of the macro-related documentation twice, I still don't see how to do
this.

I want to transform

   (foo a b c)

to

   (list foo-a foo-b foo-c)

Here is my best attempt (using syntax/parse):

(syntax-parse #'(foo a b c)
   [(f:id s:id ...)
(list (format-id #'f "foo-~a" #'s) ...)])

This yields the error message

   syntax: missing ellipsis with pattern variable in template

In fact, what I want is do something like map over the ellipsis pattern,
but I haven't seen any example for doing this.

Help, please!

Thanks in advance,
   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] Re: Official Docker images for Racket

2015-09-03 Thread Daniel Brunner
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] Official Docker images for Racket

2015-09-03 Thread Daniel Brunner
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] Lost in ellipsis depths

2015-09-03 Thread Konrad Hinsen
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

2015-09-03 Thread Tim Brown
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] Re: Official Docker images for Racket

2015-09-03 Thread Jack Firth
> 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] More Racket Place abuse^H^H^H^H^H issues

2015-09-03 Thread Matthew Flatt
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.


Re: [racket-users] Re: help on coding finite state automata

2015-09-03 Thread Nguyen Linh Chi
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: Official Docker images for Racket

2015-09-03 Thread Robby Findler
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.