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

2015-10-13 Thread Linh Chi Nguyen
oh if you dont like adding 0. maybe you can use the keyword #:final instead of #:break (they say it does just one more iteration before breaking the loop) On Wednesday, 14 October 2015 05:53:03 UTC+2, Linh Chi Nguyen wrote: > Isnt this the reason we should add 0 at the beginning of the list? >

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

2015-10-13 Thread Nguyen Linh Chi
Isnt this the reason we should add 0 at the beginning of the list? On 13/ott/2015, at 22:38, Matthias Felleisen wrote: > > Welcome to Racket v6.3.0.1. >> (define r .8) >> (for/last ([p '(a b c d)][f '(.2 .5 .7 1)] #:break (< r f)) p) > 'c > > Or WORSE: > >> (define r (random)) >> r > 0.01110

Re: [racket-users] Long-term Runtime session state

2015-10-13 Thread Daniel Feltey
> I just never found any good docs on how to do that. Near as I can tell, runtime linking of a unit is even MORE verbose and persnickety than just > manually typing in all the procedures you want to pass to a callback Some of the verbosity of units can be reduced using the "inference" features t

Re: [racket-users] Long-term Runtime session state

2015-10-13 Thread Nota Poin
On Tuesday, October 13, 2015 at 11:40:12 PM UTC, Alexis King wrote: > units Oh uh, conceivably you could have "code" that provided a live session object on linking, and handled session refreshing internally, then just link that with units that have session dependant code. I just never found any

Re: [racket-users] Long-term Runtime session state

2015-10-13 Thread Neil Van Dyke
I usually prefer to do something like for the `roomba` object in "http://www.neilvandyke.org/racket-roomba/";. See how there's a `current-roomba` Racket parameter, which provides a default value for the `#:roomba` optional argument for each procedure. So, users of the code can pass around the

Re: [racket-users] Long-term Runtime session state

2015-10-13 Thread Nota Poin
On Tuesday, October 13, 2015 at 11:40:12 PM UTC, Alexis King wrote: > Have you taken a look at parameters? Short answer: yes. Long answer: they're convenient thread-local globals, but still feel like globals to me. (define a (make-parameter 0)) (define (called-at-hopefully-regular-intervals) (

Re: [racket-users] Long-term Runtime session state

2015-10-13 Thread Alexis King
Have you taken a look at parameters? http://docs.racket-lang.org/guide/parameterize.html http://docs.racket-lang.org/reference/parameters.html There is also a way to “link units at runtime”, conveniently called “units”. http://docs.racket-lang.org/guide/units.html?q=unites#%28tech._unit%29 http:

[racket-users] Long-term Runtime session state

2015-10-13 Thread Nota Poin
How do you deal with long-term state that your programming logic depends on, but is only available at run-time? A persistent connection to a database, or an RPC server for instance, or a logged in user account. Do you use parameters? Session objects? Just raw globals? Or something stranger? Thi

Re: [racket-users] Re: Case for net/url.rkt to read HTTP proxy servers from environment

2015-10-13 Thread Paolo Giarrusso
On Tuesday, October 13, 2015 at 9:21:08 PM UTC+2, William Hatch wrote: > I would like to see it fall back on HTTP_PROXY if PLT_HTTP_PROXY is not found. +1 > It is annoying that the cases vary (eg. wget uses http_proxy and https_proxy, > curl uses http_proxy and HTTPS_PROXY), but maybe we could pr

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

2015-10-13 Thread Gustavo Massaccesi
:( . I tried few modifications, but I didn't get any improvement. I think that the recalculation of the population is used very seldom, so any change there will not affect the speed too much. Most of the time is used in the matches, but I don't have any suggestion for it (that doesn't include ugli

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

2015-10-13 Thread Matthias Felleisen
Welcome to Racket v6.3.0.1. > (define r .8) > (for/last ([p '(a b c d)][f '(.2 .5 .7 1)] #:break (< r f)) p) 'c Or WORSE: > (define r (random)) > r 0.011105628290672482 > (for/last ([p '(a b c d)][f '(.2 .5 .7 1)] #:break (< r f)) p) #f On Oct 13, 2015, at 3:37 PM, Nguyen Linh Chi wrote:

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

2015-10-13 Thread Nguyen Linh Chi
the list 0 isnt a bug. I add it because #:break will break the fitness vector at r < f. For example, Population : a b c d Cumulative fitness .2 .5 .7 1 If the random r = .8, it means that the lottery points to the interval of automaton d. But #:break will breaks at .7, and the associated autom

Re: [racket-users] Re: Case for net/url.rkt to read HTTP proxy servers from environment

2015-10-13 Thread William Hatch
I would like to see it fall back on HTTP_PROXY if PLT_HTTP_PROXY is not found. It is annoying that the cases vary (eg. wget uses http_proxy and https_proxy, curl uses http_proxy and HTTPS_PROXY), but maybe we could prefer the one in all caps and fall back on lowercase. My last job was behind a pr

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

2015-10-13 Thread Nguyen Linh Chi
Hi Mathias, thank you so much for helping me a lot. You can use the code as you want, i still have tons of them on my github. (Just dont use it against me ok :D ) I'd try to see through your list of suggestions. About the automata payoff. There are 2 different things that are always mixed up: r

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

2015-10-13 Thread Matthias Felleisen
p.s. One more question. Why do you 'reset' the payoff for automata after each round? Shouldn't they carry along their overall, historical payoff? On Oct 13, 2015, at 1:40 PM, Matthias Felleisen wrote: > > 1. Your code is a good example for something that we could use as a > benchmark, an

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

2015-10-13 Thread Matthias Felleisen
See repo. I special-purposed shuffle for my data rep. On Oct 13, 2015, at 12:39 PM, Alex Knauth wrote: > I've started on that, but shuffle doesn't exist properly yet for generic > collections. I could just use (shuffle (sequence->list )), but, what > would be the best way of representin

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

2015-10-13 Thread Matthias Felleisen
1. Your code is a good example for something that we could use as a benchmark, and working on it has helped me find a couple of problems in drracket and typed racket. Thanks for triggering my activity. I'll stop soon. 2. I figured out that your code was general so you could accommodate more s

Re: [racket-users] Puzzle

2015-10-13 Thread Jens Axel Søgaard
2015-10-13 19:16 GMT+02:00 Matthew Flatt : > At Tue, 13 Oct 2015 19:10:54 +0200, Jens Axel Søgaard wrote: > > I think I get it - if sort is a macro. > > The `define` form that supports keyword arguments can expand to a macro > definition. As an example, try the macro stepper on > > #lang racke

Re: [racket-users] Puzzle

2015-10-13 Thread Matthew Flatt
At Tue, 13 Oct 2015 19:10:54 +0200, Jens Axel Søgaard wrote: > 2015-10-12 14:48 GMT+02:00 Matthew Flatt : > > > At Mon, 12 Oct 2015 13:23:48 +0200, Jens Axel Søgaard wrote: > > > In DrRacket with just #lang racket in the definitions window. > > > Click Run. > > > > > > Welcome to DrRacket, ver

Re: [racket-users] Puzzle

2015-10-13 Thread Jens Axel Søgaard
2015-10-12 14:48 GMT+02:00 Matthew Flatt : > At Mon, 12 Oct 2015 13:23:48 +0200, Jens Axel Søgaard wrote: > > In DrRacket with just #lang racket in the definitions window. > > Click Run. > > > > Welcome to DrRacket, version 6.3.0.1--2015-10-12(a683542/a) [3m]. > > Language: racket; memory

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

2015-10-13 Thread Alex Knauth
I've started on that, but shuffle doesn't exist properly yet for generic collections. I could just use (shuffle (sequence->list )), but, what would be the best way of representing this? Generic collections give you the freedom of creating a new type of data structure just for shuffled sequen

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

2015-10-13 Thread Benjamin Greenman
> > - why you use [i (in-range 10)] in all for loop? what's the difference > with [i 10]. they both produce stream, right? Yes, but `in-range` runs faster because of "types". Here's a little example: #lang racket/base (define N (expt 10 7)) (time (for ([n (in-range N)]) (void))) ;; cpu time: 3

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

2015-10-13 Thread Linh Chi Nguyen
Matthias you work like a machine, too fast. Anyway, I have no idea what is type or not type. But I have some general remarks: 1. A general automaton can have many states, say, 10 states. so the action in each state can be either cooperate or defect (this is a deterministic automaton, for a pro

Re: [racket-users] setting default font face and size for a text%

2015-10-13 Thread David T. Pierson
On Mon, Oct 12, 2015 at 09:08:45AM -0500, Robby Findler wrote: > That will work for newly typed text. Other code might changed the style and > copying and pasting styled text may change it. You can use after-insert to > change the style for those cases. Or maybe you want to allow that. OK thanks.