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

2015-10-11 Thread Linh Chi Nguyen
Thank you very much,
Im trying to see it. However Im very unfamiliar with module in racket.

So far I can only answer you this:

about your comment 

> [define survivors (drop population speed)]
> ;; MF: THIS LOOKS LIKE IT MAY "RESURRECT" AUTOM. THAT ARE ALIVE
> [define successors (randomise-over-fitness accum-fitness population speed)]

The point of the simulation is that it "ressurect" already available automata, 
regarding their fitness. Hence who has higher fitness gets more offspring and 
grows in size gradually (at the expense of the poor doers).

What is not right here is the word "ressurect" and it catches your intuition.

I'm not a native English speaker and they are complaining that I should get a 
native English speaker to proofread my paper. Sorry for that :)

On Sunday, 11 October 2015 05:07:02 UTC+2, Matthias Felleisen  wrote:
> I forked, Racket-ized, and gained some speed (~2x). 
> 
> 

-- 
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] running racket command line, load mode works but module mode doesnt

2015-10-11 Thread Daniel Brunner

Hi,

I try to help and hope I do not mess things up. I found those start up 
things a bit tricky as well.


The main question is: What is available when you want to eval with the 
-e option? (more technically: what bindings does your current namespace 
provide at that point?)


The concept of namespaces is explained here: 
http://docs.racket-lang.org/guide/eval.html?q=namespace#%28tech._namespace%29


When you use the "-e" switch Racket requires racket/init. And 
racket/init provides all bindings from racket (plus some more from 
racket/enter and racket/help):


```
(provide (all-from-out racket
   racket/enter
   racket/help))
```

That's described at http://docs.racket-lang.org/guide/racket.html and in 
more detail in the reference at 
http://docs.racket-lang.org/reference/running-sa.html#%28part._init-actions%29


If you use the "-f" switch to "load" a file you get a top-level 
environment like in interaction mode with all the bindings from "racket".



But if you use module loading with -t (or other module loading switches) 
that is simply not the case. Then the top-level environment contains no 
bindings (not even the binding for function calls).



Given a file foo.rkt

```
#lang racket

(provide hello)

(define (hello)
  (display "Hello, world!\n"))
```

even this call fails:

$ racket -t foo.rkt -e '(+ 1 2)'

(That's because not even the function calls are provided.)

There are several ways to get your module "running":


You could provide a submodule `main` in your which is evaluated when 
your module is required by the racket executable:


Add
```
(module+ main
  (hello)
  )
```

and then "racket -t foo.rkt" prints "Hello, world!".


If you want to use "-e" (e.g. for testing) you need more bindings from 
racket. You could require "racket" with -l:


$ racket -t foo.rkt -l racket -e '(hello)'


Or your module could provide the bindings from racket. Then you could 
add something like


```
(provide (all-from-out racket)
```

in the foo.rkt module.


To sum up: When using interactive or load mode you get the bindings from 
racket, racket/init at the top-level environment. But if you use module 
mode your top-level environment is empty in the beginning.



Kind regards,
Daniel


Am 10.10.2015 um 20:29 schrieb Linh Chi Nguyen:

Hi everyone,
The situation is that I have a racket file with the same code but 2 version, 
one in module and one in load mode.

```
hi.rkt is in load mode
```

```
bye.rkt is the same code but in module mode

#lang racket
(provide run-some-commands)

```

Both work just fine if I use a REPL.

The load mode:
```
~@laptop$ racket
Welcome to Racket v6

(load "hi.rkt")
(run-some-commands x y z)

...
```

Or as a module
```
~@laptop$ racket
Welcome to Racket v6

(require "bye.rkt")
(run-some-commands x y z)

...
```

Now the problem is when I want to run the command without loading a REPL. I 
follow this doc (http://docs.racket-lang.org/guide/racket.html), it works just 
fine if i use the load mode:

```
~@laptop$ racket -f hi.rkt -e '(run-some-commands x y z)'
```

However, if i use the module mode, it says nothing, sometimes it says bye.rkt 
is undefined.

```
~@laptop$ racket bye.rkt -e '(run-some-commands x y z)'
```

I'm very confused because Racket recommends to use module instead of load mode.

Any help?

Thank you,
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] crash in nightly build

2015-10-11 Thread Dmitry Pavlov

Matthew,

It seems that I have lost my grip on the crash.
It has not happened for almost a week---neither with the version
that I build myself, nor with the nightly build where I definitely
saw it. I did not update Racket during this time.
I did not do anything else. I have no idea why it is gone. Sorry.

On the other hand, business runs as usual now, I run
my programs daily, and there is a chance that the conditions
for the crash will repeat. In that case, I surely will let you know.

Best regards,

Dmitry


On 10/05/2015 05:32 PM, Matthew Flatt wrote:

At Mon, 05 Oct 2015 17:16:34 +0300, Dmitry Pavlov wrote:

I am going to get you a stack trace.
Am I correct that in order to get the stack trace, I have to rebuild
Racket with -G and run it in gdb?


Racket builds with `-g` by default, but `make install` uses `strip`.
You could configure with `--enable-strip`, or just run
"build/racket/racket3m" directly. You might even get a useful stack
trace running the stripped version, since many function names are
preserved for access via dlopen().


Here is another interesting thing that I was able to notice.
As soon as I purged the "compiled" directories from the code tree,
the crashes ceased. I did several consecutive successful runs.
I ran just "racket myprogram", without "raco make" or DrRacket.
Then I executed "raco make myprogram" -- and the very next run
has crashed after ~7h of running.

How do you think, does it make sense that stored bytecode can
cause the crash or is it just a coincidence?


Yes, that's possible; the bytecode format is one thing that changed
with the new expander. The fixed bug related to the new expander had to
do with bytecode, but that one was about interrupting a bytecode load.

You might check whether the `-d` flag has any effect. That flag
disables on-demand bytecode loading.

Another possibility is that loading from source merely shifts
allocation patterns to mask an unrelated bug, but this directory sound
more promising than that, so far.



--
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-10-11 Thread Linh Chi Nguyen
ok i've been trying to see through the code.

I'm not sure how github works but I pushed the changes in my repo again 
(https://github.com/ayaderaghul/sample-fsm/blob/master/fsm0.rkt). Basically, I 
rewrite the automaton module (description and behavior) because previously I 
made a confusion between the number of the states and the number of actions for 
each state. Now the automaton is less readable but more simple.

I also add some test that can be run with 
```
~laptop$ raco test fsm0.rkt
```

However I dont know to run this code without a repl.
Because the whole file fsm0.rkt is a module and it has many nested modules 
inside, and the command i need is in the nested one. There is a special module 
that has this command:

```
(module* main #f
(run))
```

So if i want to run a trial of the file, i open a repl:

```
~laptop$ racket
> (require (submod "fsm0.rkt" tv))
> (run)
```
and it runs and plot the result.

I dont want to open a repl. How to run the command right in the terminal 
(Because later on i want to run the command with arguments in the terminal)? 
for example, I've tried this but it doesnt work:

```
~laptop$ racket fsm0.rkt '(require (submod "fsm0.rkt" tv))' '(run)'
```

Thank you,
Chi




On Sunday, 11 October 2015 09:24:07 UTC+2, Linh Chi Nguyen  wrote:
> Thank you very much,
> Im trying to see it. However Im very unfamiliar with module in racket.
> 
> So far I can only answer you this:
> 
> about your comment 
> 
> > [define survivors (drop population speed)]
> > ;; MF: THIS LOOKS LIKE IT MAY "RESURRECT" AUTOM. THAT ARE ALIVE
> > [define successors (randomise-over-fitness accum-fitness population speed)]
> 
> The point of the simulation is that it "ressurect" already available 
> automata, regarding their fitness. Hence who has higher fitness gets more 
> offspring and grows in size gradually (at the expense of the poor doers).
> 
> What is not right here is the word "ressurect" and it catches your intuition.
> 
> I'm not a native English speaker and they are complaining that I should get a 
> native English speaker to proofread my paper. Sorry for that :)
> 
> On Sunday, 11 October 2015 05:07:02 UTC+2, Matthias Felleisen  wrote:
> > I forked, Racket-ized, and gained some speed (~2x). 
> > 
> >

-- 
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] running racket command line, load mode works but module mode doesnt

2015-10-11 Thread Linh Chi Nguyen
Dear Daniel, 
thank you for your answer, I have a sample code that I describe the same 
problem here in this thread (the last post of mine, you dont need to read the 
whole thread) including what command in which nested module I want to call:

https://groups.google.com/forum/?hl=en-GB#!topic/racket-users/4o1goSwrLHA

About namespace and binding stuff, I'm completely lost (I'm an economics 
student).
=.=~


On Sunday, 11 October 2015 11:54:58 UTC+2, daniel  wrote:
> Hi,
> 
> I try to help and hope I do not mess things up. I found those start up 
> things a bit tricky as well.
> 
> The main question is: What is available when you want to eval with the 
> -e option? (more technically: what bindings does your current namespace 
> provide at that point?)
> 
> The concept of namespaces is explained here: 
> http://docs.racket-lang.org/guide/eval.html?q=namespace#%28tech._namespace%29
> 
> When you use the "-e" switch Racket requires racket/init. And 
> racket/init provides all bindings from racket (plus some more from 
> racket/enter and racket/help):
> 
> ```
> (provide (all-from-out racket
> racket/enter
> racket/help))
> ```
> 
> That's described at http://docs.racket-lang.org/guide/racket.html and in 
> more detail in the reference at 
> http://docs.racket-lang.org/reference/running-sa.html#%28part._init-actions%29
> 
> If you use the "-f" switch to "load" a file you get a top-level 
> environment like in interaction mode with all the bindings from "racket".
> 
> 
> But if you use module loading with -t (or other module loading switches) 
> that is simply not the case. Then the top-level environment contains no 
> bindings (not even the binding for function calls).
> 
> 
> Given a file foo.rkt
> 
> ```
> #lang racket
> 
> (provide hello)
> 
> (define (hello)
>(display "Hello, world!\n"))
> ```
> 
> even this call fails:
> 
> $ racket -t foo.rkt -e '(+ 1 2)'
> 
> (That's because not even the function calls are provided.)
> 
> There are several ways to get your module "running":
> 
> 
> You could provide a submodule `main` in your which is evaluated when 
> your module is required by the racket executable:
> 
> Add
> ```
> (module+ main
>(hello)
>)
> ```
> 
> and then "racket -t foo.rkt" prints "Hello, world!".
> 
> 
> If you want to use "-e" (e.g. for testing) you need more bindings from 
> racket. You could require "racket" with -l:
> 
> $ racket -t foo.rkt -l racket -e '(hello)'
> 
> 
> Or your module could provide the bindings from racket. Then you could 
> add something like
> 
> ```
> (provide (all-from-out racket)
> ```
> 
> in the foo.rkt module.
> 
> 
> To sum up: When using interactive or load mode you get the bindings from 
> racket, racket/init at the top-level environment. But if you use module 
> mode your top-level environment is empty in the beginning.
> 
> 
> Kind regards,
> Daniel
> 
> 
> Am 10.10.2015 um 20:29 schrieb Linh Chi Nguyen:
> > Hi everyone,
> > The situation is that I have a racket file with the same code but 2 
> > version, one in module and one in load mode.
> >
> > ```
> > hi.rkt is in load mode
> > ```
> >
> > ```
> > bye.rkt is the same code but in module mode
> >
> > #lang racket
> > (provide run-some-commands)
> >
> > ```
> >
> > Both work just fine if I use a REPL.
> >
> > The load mode:
> > ```
> > ~@laptop$ racket
> > Welcome to Racket v6
> >> (load "hi.rkt")
> >> (run-some-commands x y z)
> > ...
> > ```
> >
> > Or as a module
> > ```
> > ~@laptop$ racket
> > Welcome to Racket v6
> >> (require "bye.rkt")
> >> (run-some-commands x y z)
> > ...
> > ```
> >
> > Now the problem is when I want to run the command without loading a REPL. I 
> > follow this doc (http://docs.racket-lang.org/guide/racket.html), it works 
> > just fine if i use the load mode:
> >
> > ```
> > ~@laptop$ racket -f hi.rkt -e '(run-some-commands x y z)'
> > ```
> >
> > However, if i use the module mode, it says nothing, sometimes it says 
> > bye.rkt is undefined.
> >
> > ```
> > ~@laptop$ racket bye.rkt -e '(run-some-commands x y z)'
> > ```
> >
> > I'm very confused because Racket recommends to use module instead of load 
> > mode.
> >
> > Any help?
> >
> > Thank you,
> > 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] running racket command line, load mode works but module mode doesnt

2015-10-11 Thread Linh Chi Nguyen
Dear Daniel, 
I have blindly tried and so far these two things work for me:

1.
Add this to the end of the file (maybe module* main #f...)
```
(module+ main
   (hello)
   )
```
and then "racket -t foo.rkt" prints "Hello, world!".

2. 
If you want to use "-e" (e.g. for testing) you need more bindings from
racket. You could require "racket" with -l:

$ racket -t foo.rkt -l racket -e '(hello)'

Thank you so so much Daniel,
Best,
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-10-11 Thread Linh Chi Nguyen
Sorry for the emails.

But I'd like to post that the question of how to require a module then evaluate 
a command is answered here:

https://groups.google.com/forum/#!topic/racket-users/byL7W1yktas

by Daniel.

Thank you so much for all your help and patience,
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.


[racket-users] Naming for generalization of find-min and find-max?

2015-10-11 Thread Alex Knauth
Hi,

Alexis King and I were discussing adding versions of argmin and argmax to the 
alexis/collection library, but we agreed that find-min and find-max were 
clearer names. Then we came up with a generalization of those that would take 
an ordering procedure (< for find-min and > for find-max), and find the element 
that had a property greater/less than the properties of all the other elements, 
by the ordering procedure (not restricted to numbers). 

The problem was naming it. We thought of `find-best` and `find-most-relevant`, 
but `find-best` would be confusing when it's being used to find the worst case, 
and `find-most-relevant` seems better but to wordy. 

Do any of you have any ideas?

Examples:
> (the-function < first '((3 pears) (1 banana) (2 apples))) ; find-min would be 
> a shorthand for this
'(1 banana)
> (the-function > first '((3 pears) (1 banana) (2 apples))) ; find-max would be 
> a shorthand for this
'(3 pears)
> (the-function stringstring second) '((3 pears) (1 
> banana) (2 apples)))
'(2 apples)
> (the-function string>? (compose1 symbol->string second) '((3 pears) (1 
> banana) (2 apples)))
'(3 pears)

https://github.com/lexi-lambda/racket-alexis-collections/pull/9#issuecomment-145727937
 


-- 
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] Naming for generalization of find-min and find-max?

2015-10-11 Thread Robby Findler
Find-best is right to me. The "best" under < is the most negative number.
Find-maximal is also okay and slightly more accurate.

Robby

On Sunday, October 11, 2015, Alex Knauth  wrote:

> Hi,
>
> Alexis King and I were discussing adding versions of argmin and argmax to
> the alexis/collection library, but we agreed that find-min and find-max
> were clearer names. Then we came up with a generalization of those that
> would take an ordering procedure (< for find-min and > for find-max), and
> find the element that had a property greater/less than the properties of
> all the other elements, by the ordering procedure (not restricted to
> numbers).
>
> The problem was naming it. We thought of `find-best` and
> `find-most-relevant`, but `find-best` would be confusing when it's being
> used to find the worst case, and `find-most-relevant` seems better but to
> wordy.
>
> Do any of you have any ideas?
>
> Examples:
> > (the-function < first '((3 pears) (1 banana) (2 apples))) ; find-min
> would be a shorthand for this
> '(1 banana)
> > (the-function > first '((3 pears) (1 banana) (2 apples))) ; find-max
> would be a shorthand for this
> '(3 pears)
> > (the-function stringstring second) '((3 pears) (1
> banana) (2 apples)))
> '(2 apples)
> > (the-function string>? (compose1 symbol->string second) '((3 pears) (1 
> > banana)
> (2 apples)))
> '(3 pears)
>
> *https://github.com/lexi-lambda/racket-alexis-collections/pull/9#issuecomment-145727937
> *
>
> --
> 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] Naming for generalization of find-min and find-max?

2015-10-11 Thread Andrew Kent
'leftmost' or 'rightmost'? Or 'find-leftmost' 'find-rightmost'? I dunno,
maybe those are more confusing. They seem to hint at the right idea to me
(at least as it relates to argument order and the relation).

On Sun, Oct 11, 2015, 6:25 PM Alex Knauth  wrote:

> Hi,
>
> Alexis King and I were discussing adding versions of argmin and argmax to
> the alexis/collection library, but we agreed that find-min and find-max
> were clearer names. Then we came up with a generalization of those that
> would take an ordering procedure (< for find-min and > for find-max), and
> find the element that had a property greater/less than the properties of
> all the other elements, by the ordering procedure (not restricted to
> numbers).
>
> The problem was naming it. We thought of `find-best` and
> `find-most-relevant`, but `find-best` would be confusing when it's being
> used to find the worst case, and `find-most-relevant` seems better but to
> wordy.
>
> Do any of you have any ideas?
>
> Examples:
> > (the-function < first '((3 pears) (1 banana) (2 apples))) ; find-min
> would be a shorthand for this
> '(1 banana)
> > (the-function > first '((3 pears) (1 banana) (2 apples))) ; find-max
> would be a shorthand for this
> '(3 pears)
> > (the-function stringstring second) '((3 pears) (1
> banana) (2 apples)))
> '(2 apples)
> > (the-function string>? (compose1 symbol->string second) '((3 pears) (1 
> > banana)
> (2 apples)))
> '(3 pears)
>
> *https://github.com/lexi-lambda/racket-alexis-collections/pull/9#issuecomment-145727937
> *
>
> --
> 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.


[racket-users] Re: Naming for generalization of find-min and find-max?

2015-10-11 Thread JCG
On Sunday, October 11, 2015 at 6:24:57 PM UTC-4, Alex Knauth wrote:
> Hi,
> 
> The problem was naming it. We thought of `find-best` and 
> `find-most-relevant`, but `find-best` would be confusing when it's being used 
> to find the worst case, and `find-most-relevant` seems better but to wordy. 
> 
> 
> Do any of you have any ideas?
> 

I had the same question for a similar set of library functions not in racket).  
I chose 'most -  'most', e.g. most negative, most positive, most length.

-- 
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] Naming for generalization of find-min and find-max?

2015-10-11 Thread Ben Lerner

  
  
What about "find-min-by"/"find-max-by"?  (Or, if it's more standard
Rackety style, "find-min/by" and "find-max/by", where the slash
denotes a variant of an otherwise common function...)

Ben

On 10/11/2015 6:24 PM, Alex Knauth
  wrote:


  
  Hi,
  
  
  Alexis King and I were discussing adding versions of argmin and
  argmax to the alexis/collection library, but we agreed that
  find-min and find-max were clearer names. Then we came up with a
  generalization of those that would take an ordering procedure
  (< for find-min and > for find-max), and find the element
  that had a property greater/less than the properties of all the
  other elements, by the ordering procedure (not restricted to
  numbers). 
  
  
  The problem was naming it. We thought of `find-best`
and `find-most-relevant`, but `find-best` would be confusing
when it's being used to find the worst case, and
`find-most-relevant` seems better but to wordy. 
  
  
  Do any of you have any ideas?
  
  
  Examples:
  > (the-function
  < first '((3 pears) (1 banana) (2
  apples))) ; find-min would be a shorthand for this
  '(1 banana)
  > (the-function
  > first '((3 pears) (1 banana) (2 apples)))
  ; find-max would be a shorthand for this
  '(3 pears)
  > (the-function
  stringstring second) '((3 pears) (1
  banana) (2 apples)))
  '(2 apples)
  
>
(the-function string>? (compose1 symbol->string
second) '((3 pears) (1 banana) (2 apples)))
'(3 pears)
  
  
  
  https://github.com/lexi-lambda/racket-alexis-collections/pull/9#issuecomment-145727937
  
  
  -- 
  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] Naming for generalization of find-min and find-max?

2015-10-11 Thread Matthias Felleisen

argbest 



> On Oct 11, 2015, at 6:24 PM, Alex Knauth  wrote:
> 
> Hi,
> 
> Alexis King and I were discussing adding versions of argmin and argmax to the 
> alexis/collection library, but we agreed that find-min and find-max were 
> clearer names. Then we came up with a generalization of those that would take 
> an ordering procedure (< for find-min and > for find-max), and find the 
> element that had a property greater/less than the properties of all the other 
> elements, by the ordering procedure (not restricted to numbers). 
> 
> The problem was naming it. We thought of `find-best` and 
> `find-most-relevant`, but `find-best` would be confusing when it's being used 
> to find the worst case, and `find-most-relevant` seems better but to wordy. 
> 
> Do any of you have any ideas?
> 
> Examples:
> > (the-function < first '((3 pears) (1 banana) (2 apples))) ; find-min would 
> > be a shorthand for this
> '(1 banana)
> > (the-function > first '((3 pears) (1 banana) (2 apples))) ; find-max would 
> > be a shorthand for this
> '(3 pears)
> > (the-function stringstring second) '((3 pears) (1 
> > banana) (2 apples)))
> '(2 apples)
> > (the-function string>? (compose1 symbol->string second) '((3 pears) (1 
> > banana) (2 apples)))
> '(3 pears)
> 
> https://github.com/lexi-lambda/racket-alexis-collections/pull/9#issuecomment-145727937
>  
> 
> 
> 
> -- 
> 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] help on coding finite state automata

2015-10-11 Thread Matthias Felleisen

I have pushed some more cleanups, more speed. 
I added another question to the “spawning” procedure. 




> On Oct 10, 2015, at 11:06 PM, Matthias Felleisen  wrote:
> 
> I forked, Racket-ized, and gained some speed (~2x). 
> 
> 
> 
>> On Sep 6, 2015, at 5:21 AM, Nguyen Linh Chi > > wrote:
>> 
>> Dear All,
>> thanks for all your help, im writing the code to generate a population of 
>> fsm, playing a repeated game and the population evolves over time. (no 
>> mutation yet). here on my github just fyi:
>> 
>> https://github.com/ayaderaghul/sample-fsm 
>> 
>> 
>> Btw, the blogger suggests that because the automaton only needs to know the 
>> current-state, if the population scales big, we just need to separate the 
>> current-state as a single atom outside the machine itself (for better 
>> performance). 
>> 
>> I hope this may helps make the thread more complete.
>> 
>> 
>> On 4 September 2015 at 20:50, > > wrote:
>> On Friday, September 4, 2015 at 9:31:36 AM UTC-4, Michael Myers wrote:
>> > 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're a bit fragile, so use at your own risk.
>> 
>> Sorry for the duplicate, this was sent yesterday, and only arived just now.
>> 
>> --
>> 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 
>> .
>> 
>> 
>> 
>> -- 
>> Nguyen Linh 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 
>> .
> 
> 
> -- 
> 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] Naming for generalization of find-min and find-max?

2015-10-11 Thread Alex Knauth
My responses to Robby Findler, Andrew Kent, JCG, Ben Lerner, and Matthias 
Felleisen:

Something I should have said before:
I want this to be one abstraction over both find-min and find-max.

> On Oct 11, 2015, at 6:29 PM, Robby Findler  
> wrote:
> 
> Find-best is right to me. The "best" under < is the most negative number. 
> Find-maximal is also okay and slightly more accurate. 


Alexis King didn't like "best" because it seems to opinionated and too specific 
about good things (if I understand correctly), and I agree that it could be 
confusing if you're using best to find the worst case. I personally like 
find-best so far, but I don't know about Alexis or anybody else. 

ps I don't like maximal because it feels too number-y.

> On Oct 11, 2015, at 8:56 PM, Robby Findler  
> wrote:
> 
> :)
> 
> Maximal isn't numbery. It is more accurate because you might not have a total 
> order (and thus not a single best).


Um, I think of it as number-y. Maybe you and other awesome people abstracted 
this stuff out, but I think of it as number-y.

Another thing is that since this is a sort of generalization of both find-min 
and find-max, it should not use words like maximal or optimal, because that 
implies find-max but not find-min. I'm not sure about that though. You could 
make that same argument against best, but best feels far enough away from max 
that you can imagine the best being the minimum. That's just a general feeling 
though.

> On Oct 11, 2015, at 7:43 PM, Andrew Kent  wrote:
> 'leftmost' or 'rightmost'? Or 'find-leftmost' 'find-rightmost'? I dunno, 
> maybe those are more confusing. They seem to hint at the right idea to me (at 
> least as it relates to argument order and the relation).
> 
I think I would find those confusing.
Also note that we were talking about one abstracted function for both find-min 
and find-max, not two, one for each of them. Also also don't think this should 
have to imply sorting, because it doesn't have to sort through the whole list. 
It only has to find the best or most relevant element, not the order of each 
one.

I do see what you are saying, but it doesn't seem as clear as find-best or 
find-most-relevant.

> On Oct 11, 2015, at 9:07 PM, Ben Lerner  wrote:
> 
> What about "find-min-by"/"find-max-by"?  (Or, if it's more standard Rackety 
> style, "find-min/by" and "find-max/by", where the slash denotes a variant of 
> an otherwise common function...)


Hello. I think find-min-by and find-max-by would conceptually be good names for 
find-min and find-max, but not for the function abstracting over both of them. 
To me the by implies that there's some property that it's comparing them by, 
and that's already what find-min and find-max do (which is exactly what argmin 
and argmax do). 

> On Oct 11, 2015, at 8:45 PM, JCG  wrote:
> 
> I had the same question for a similar set of library functions not in 
> racket).  I chose 'most -  'most', e.g. most negative, most positive, most 
> length.

Most seems to number-y again. I guess I think of maximal, optimal, and most as 
quantitative things, but best and most-relevant as qualitative things. Maybe 
that's why I think of them as number-y. They don't feel as abstract.

I want this to be an abstraction over both find-min and find-max.

> On Oct 11, 2015, at 9:39 PM, Matthias Felleisen  wrote:
> 
> argbest 

Um, ok. If we were making the naming consistent with argmin and argmax, that 
would be good. But we renamed those to find-min and find-max because we thought 
arg... was confusing. I know we try not to be confusing here. 

> On Sun, Oct 11, 2015, 6:25 PM Alex Knauth  > wrote:
> Hi,
> 
> Alexis King and I were discussing adding versions of argmin and argmax to the 
> alexis/collection library, but we agreed that find-min and find-max were 
> clearer names. Then we came up with a generalization of those that would take 
> an ordering procedure (< for find-min and > for find-max), and find the 
> element that had a property greater/less than the properties of all the other 
> elements, by the ordering procedure (not restricted to numbers). 
> 
> The problem was naming it. We thought of `find-best` and 
> `find-most-relevant`, but `find-best` would be confusing when it's being used 
> to find the worst case, and `find-most-relevant` seems better but to wordy. 
> 
> Do any of you have any ideas?
> 
> Examples:
> > (the-function < first '((3 pears) (1 banana) (2 apples))) ; find-min would 
> > be a shorthand for this
> '(1 banana)
> > (the-function > first '((3 pears) (1 banana) (2 apples))) ; find-max would 
> > be a shorthand for this
> '(3 pears)
> > (the-function stringstring second) '((3 pears) (1 
> > banana) (2 apples)))
> '(2 apples)
> > (the-function string>? (compose1 symbol->string second) '((3 pears) (1 
> > banana) (2 apples)))
> '(3 pears)
> 
> https://github.com/lexi-lambda/racket-alexis-collections/pull/9#issuecomment-145727937
>  
> 

Re: [racket-users] Naming for generalization of find-min and find-max?

2015-10-11 Thread Matthias Felleisen

> On Oct 11, 2015, at 10:00 PM, Alex Knauth  wrote:
> 
> Um, ok. If we were making the naming consistent with argmin and argmax, that 
> would be good. But we renamed those to find-min and find-max because we 
> thought arg... was confusing. I know we try not to be confusing here. 
> 


You will be far more confusing for people who know the old names (from 
1960foobar) and can’t find the new ones. 

-- 
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] Naming for generalization of find-min and find-max?

2015-10-11 Thread Alex Knauth

> On Oct 11, 2015, at 10:41 PM, Nadeem Abdul Hamid  wrote:
> find-optimal  ?
> 
Originally I thought "optimal = maximal" and I didn't like it because it felt 
too number-y and too close to max.

Robby got me to realize that optimal doesn't imply numbers, and is really 
closer to best.
But then I thought, we're really saying best anyway, just in latin.

But Alexis? What do you think?

> On Oct 11, 2015 6:25 PM, "Alex Knauth"  > wrote:
> >
> > Hi,
> >
> > Alexis King and I were discussing adding versions of argmin and argmax to 
> > the alexis/collection library, but we agreed that find-min and find-max 
> > were clearer names. Then we came up with a generalization of those that 
> > would take an ordering procedure (< for find-min and > for find-max), and 
> > find the element that had a property greater/less than the properties of 
> > all the other elements, by the ordering procedure (not restricted to 
> > numbers). 
> >
> > The problem was naming it. We thought of `find-best` and 
> > `find-most-relevant`, but `find-best` would be confusing when it's being 
> > used to find the worst case, and `find-most-relevant` seems better but to 
> > wordy. 
> >
> > Do any of you have any ideas?
> >
> > Examples:
> > > (the-function < first '((3 pears) (1 banana) (2 apples))) ; find-min 
> > > would be a shorthand for this
> > '(1 banana)
> > > (the-function > first '((3 pears) (1 banana) (2 apples))) ; find-max 
> > > would be a shorthand for this
> > '(3 pears)
> > > (the-function stringstring second) '((3 pears) (1 
> > > banana) (2 apples)))
> > '(2 apples)
> > > (the-function string>? (compose1 symbol->string second) '((3 pears) (1 
> > > banana) (2 apples)))
> > '(3 pears)
> >
> > https://github.com/lexi-lambda/racket-alexis-collections/pull/9#issuecomment-145727937
> >  
> > 
> >
> > -- 
> > 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] Naming for generalization of find-min and find-max?

2015-10-11 Thread Alexis King
> You will be far more confusing for people who know the old names (from 
> 1960foobar) and can’t find the new ones. 

I have been looking into how to add index aliases for Scribble docs to address 
this problem. This may lead to another mailing list thread.

-- 
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] above/beside

2015-10-11 Thread Byron Davies
Is there a reason why above and beside (from 2htdp) don’t “do the right thing” 
when supplied with a single argument?

I have multiple workarounds in my code that look like:

(if (empty? (cdr lst))
(car lst)
(apply above lst))

Should I just shadow above and beside with my own versions, or would other 
people find the single-argument versions useful?

Byron

-- 
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-10-11 Thread byrondavies
Chi, if you have really like finite state automata, you might be interested in 
a new product from Micron called the Automata Processor (AP) 
http://www.micronautomata.com.  A single chip has (I think) 256K fsa elements 
operating in massive parallelism.  It's particularly designed for things like 
"graph analysis, pattern matching, and data analytics", and can recognize large 
numbers of complex patterns simultaneously in streams of data at near gigabit 
rates.

The AP is implemented as an co-processor (with up to 8 chips) for a PC, and 
currently has a C-based API development environment and API.  It could sorely 
use a Racket interface and development environment.

Byron

On Thursday, September 3, 2015 at 7:29:33 AM UTC-7, 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 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] Representing invalid values for non-negative integer variables

2015-10-11 Thread Byron Davies
In my state object for 2htdp, I have entries that are normally natural numbers. 
 When the value of a particular entry is not meaningful during a certain 
activity, I could just leave the value as whatever it was before, but I would 
prefer to set it to an invalid value (such as -1 or #f) to indicate that it’s 
not being used.  Is there any stylistic reason to prefer one over the other, 
and will the answer be different when I use Typed Racket?

-- 
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] above/beside

2015-10-11 Thread Daniel Prager
If memory serves, this is to cater for beginning students for whom passing
a single image is more often than not an error.

I (and no doubt others) have written functions above* and beside* to do
"the right thing".

Dan

-- 
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] Representing invalid values for non-negative integer variables

2015-10-11 Thread Alexis King
The Scheme convention for absence of a value, inherited by Racket, is to use #f 
since it is the only falsy value. This make it easy to branch on the presence 
or absence of a value.

Typed Racket reinforces this convention: it has an (Option t) type constructor 
that is an alias for (U t #f), which is a union of `t` and the singleton type 
for the #f value. This cooperates well with Typed Racket’s occurrence typing so 
code that branches on the presence of a value properly typechecks.

> On Oct 11, 2015, at 10:22 PM, Byron Davies  wrote:
> 
> In my state object for 2htdp, I have entries that are normally natural 
> numbers.  When the value of a particular entry is not meaningful during a 
> certain activity, I could just leave the value as whatever it was before, but 
> I would prefer to set it to an invalid value (such as -1 or #f) to indicate 
> that it’s not being used.  Is there any stylistic reason to prefer one over 
> the other, and will the answer be different when I use Typed Racket?
> 
> -- 
> 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.