[racket-users] Specifying a contract for the end of a list

2015-05-18 Thread Alexis King
I've recently wanted a contract that lets me check the last element of a (potentially improper) list, ignoring the other elements. To do this in a general sense, I came up with this. (define (listof* init/c last/c) (flat-named-contract `(listof* ,(contract-name init/c) ,(contract-name last/

[racket-users] munger package

2015-05-18 Thread 'John Clements' via users-redirect
I’m interested in your munger package for data analysis, but … it looks like there are no docs or examples? Any plans to work on this? Thanks! John Clements -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and st

Re: [racket-users] Strange behaviour of the eq? operator in racket repl

2015-05-18 Thread Hendrik Boom
On Mon, May 18, 2015 at 08:50:50PM +0200, Jos Koot wrote: > > At the mathematical level equality is a difficult and in many cases even an > unsolvable thing. Indeed. It is suspected by some that difficulties with equality lie at the root of problems with set theory. There are two concepts of eq

RE: [racket-users] Strange behaviour of the eq? operator in racket repl

2015-05-18 Thread Jos Koot
No, what you describe is not off topic at all. It is at the core of the problem of defining what equality means. As you already have seen, there are several definitions (and cases in which a definition does not work) Kind regards, Jos -Original Message- From: Michael Tiedtke [mailto:micha

Re: [racket-users] Strange behaviour of the eq? operator in racket repl

2015-05-18 Thread Alexander D. Knauth
On May 18, 2015, at 1:19 AM, Michael Tiedtke wrote: > I'm new to Racket but even R5RS is rather clear about this issue: > > (citation from doc/r5rs/r5rs-std/r5rs-Z-H-9.html) >> (eq? 2 2) ===> unspecified In Racket, (eq? 2 2) is specified as true. It says here: http://docs.racket-lang.org/

RE: [racket-users] Strange behaviour of the eq? operator in racket repl

2015-05-18 Thread Jos Koot
A fact is that equal? does not distinguish between for example two mutable lists that happen to have the same content (whatever the "same" may mean) They may be equal? at one moment and not be equal? a little bit later. With eq? you don't have this problem, BUT that's a very distinct kind of equali

Re: [racket-users] Strange behaviour of the eq? operator in racket repl

2015-05-18 Thread Jens Axel Søgaard
2015-05-18 21:25 GMT+02:00 Michael Tiedtke : > Il giorno 18/mag/2015, alle ore 20.50, Jos Koot ha scritto: > > > I think Rackets's reference and guide are *very clear* about eq?, eqv? > and > > equal?. > > Yes, right. It was the Racket Reference to tell me exactly that eqv? is an > eq? that > work

Re: [racket-users] Strange behaviour of the eq? operator in racket repl

2015-05-18 Thread Michael Tiedtke
Il giorno 18/mag/2015, alle ore 20.50, Jos Koot ha scritto: > I think Rackets's reference and guide are *very clear* about eq?, eqv? and > equal?. Yes, right. It was the Racket Reference to tell me exactly that eqv? is an eq? that works for numbers and characters, too. I really had to look this

Re: [racket-users] Strange behaviour of the eq? operator in racket repl

2015-05-18 Thread Greg Hendershott
In my early time learning Racket, I wish someone had given me the following advice: """ For now? Just use `equal?`. `equal?` will usually do the right thing, including for numbers, strings, symbols, immutable lists, and so on. A type-specific function like `=` or `string-=?` might be a bit faster

RE: [racket-users] Strange behaviour of the eq? operator in racket repl

2015-05-18 Thread Jos Koot
I think Rackets's reference and guide are *very clear* about eq?, eqv? and equal?. They are even described well for structures and hashes and much more. Be aware, though, that in general equality can be interpreted in many ways. At the mathematical level equality is a difficult and in many cases ev

Re: [racket-users] Strange behaviour of the eq? operator in racket repl

2015-05-18 Thread Michael Tiedtke
Il giorno 18/mag/2015, alle ore 18.06, Atticus ha scritto: > I guess it's a matter of definition. I must admit that i didn't reflect > on equality that much. > > My (very limited) knowledge about that stuff comes mostly from the "The > Little Schemer" which imho explains it really well with the '

Re: [racket-users] Typed Racket: "Shuffle" Polymorphic Function problem

2015-05-18 Thread Tim Brown
Thanks Sam, I swear I came *so* close to that! I'll take a good hard look over the TR Guide; I'm sure it'll make sense. Tim On 18/05/15 17:16, Sam Tobin-Hochstadt wrote: Typed Racket doesn't bring the type variable `A` into scope on the right-hand side of the `define`, because it isn't a func

Re: [racket-users] Strange behaviour of the eq? operator in racket repl

2015-05-18 Thread Atticus
I guess it's a matter of definition. I must admit that i didn't reflect on equality that much. My (very limited) knowledge about that stuff comes mostly from the "The Little Schemer" which imho explains it really well with the 'eqan?' and 'eqlist?' procedure. The reason why i checked (eq? 'symbol

[racket-users] Racket should not cancel an OS shutdown

2015-05-18 Thread Michael Tiedtke
When I try to shutdown my Mac Racket (run from the command line) cancels the shutdown or logout. I can install an application-quit-handler (with racket/gui) like this: ;; ;; Operating System Interface Incoming (define (quit-request) ;; XXX this is called but racket still cancels

Re: [racket-users] Doing pattern matching by reader macro

2015-05-18 Thread Matthias Felleisen
Your best bet is to define a new language that overrides define after taking over the body of the module. This may even be an example in the docs. On May 18, 2015, at 9:39 AM, Mianlai Zhou wrote: > Hi Matthias, > > Thanks for answer. However, this is not what I wanted: > > I want to persi

Re: [racket-users] Doing pattern matching by reader macro

2015-05-18 Thread Mianlai Zhou
Hi Matthias, Thanks for answer. However, this is not what I wanted: I want to persist that I can write the code below (where "define" can be changed to other name): (define (f #t) 2) (define (f #f) 3) (define (f _) 0) to do what I want to do. So how should I define my "define" in order to do i

Re: [racket-users] Doing pattern matching by reader macro

2015-05-18 Thread Matthias Felleisen
#lang racket (define/match (f n) [(#t) 2] [(#f) 3] [(_) 0]) (list (f #t) (f #f) (f "where's my homework")) On May 18, 2015, at 9:04 AM, Mianlai Zhou wrote: > Hi Racketeers, > > I am a new user of Racket. > > I would want to be able to write the following segment of code: > > (defin

Re: [racket-users] Strange behaviour of the eq? operator in racket repl

2015-05-18 Thread Matthias Felleisen
SICP isn' the bible, especially not on programming language knowledge. I'd recommend checking out relevant literature instead. On May 18, 2015, at 8:24 AM, Michael Tiedtke wrote: > Structure and Interpretation of Computer Programs (sicp2) about sameness: > > https://mitpress.mit.edu/

[racket-users] Doing pattern matching by reader macro

2015-05-18 Thread Mianlai Zhou
Hi Racketeers, I am a new user of Racket. I would want to be able to write the following segment of code: (define (f #t) 2) (define (f #f) 3) (define (f _) 0) My intention is to define a function f, such that given an argument #t it will produce 2, or in case given an argument #f it will produ

Re: [racket-users] racket testing on openwrt

2015-05-18 Thread Matthew Flatt
At Mon, 18 May 2015 07:16:39 -0400, Jay McCarthy wrote: > On Sun, May 17, 2015 at 5:00 PM, Neil Van Dyke wrote: > > Can someone recommend an easy way to test Racket 9.2 pre-release on OpenWrt > > (embedded GNU/Linux, running on a normal home WiFi router)? > > > > For example, is there a big tree o

Re: [racket-users] Strange behaviour of the eq? operator in racket repl

2015-05-18 Thread Michael Tiedtke
Structure and Interpretation of Computer Programs (sicp2) about sameness: https://mitpress.mit.edu/sicp/full-text/book/book-Z-H-16.html#footnote_Temp_230 > We can consider two symbols to be ``the same'' if they consist of the same > characters in the same order. Such a definition skirts a deep is

RE: [racket-users] constant propagation

2015-05-18 Thread Jos Koot
Hi Matthias, Thanks for your clear answer. You're right, of course. I am curious, but that's not bad I think, although it may sometimes be annoying. Consider my post as a compliment, please. Thanks again, Jos _ From: Matthias Felleisen [mailto:matth...@ccs.neu.edu] Sent: lunes, 18

Re: [racket-users] constant propagation

2015-05-18 Thread Matthias Felleisen
Constant propagation is not a property of a language but its implementation. Few implementations document which transformations they currently implement. -- Matthias On May 18, 2015, at 7:11 AM, Jos Koot wrote: > Very nice constant propagation in Racket. > For example the Racket compiler

Re: [racket-users] racket testing on openwrt

2015-05-18 Thread Jay McCarthy
On Sun, May 17, 2015 at 5:00 PM, Neil Van Dyke wrote: > Can someone recommend an easy way to test Racket 9.2 pre-release on OpenWrt > (embedded GNU/Linux, running on a normal home WiFi router)? > > For example, is there a big tree of files that I could just copy onto a USB > flash drive, and run w

[racket-users] constant propagation

2015-05-18 Thread Jos Koot
Very nice constant propagation in Racket. For example the Racket compiler pre-evaluates: (let ((b 2)) (sqrt (+ 2 b))) to '2. That is what zo-parse and decompile tell me. May be I missed it, but looking for info on constant propagation I found no info about this in the docs. If there is info, please

[racket-users] Typed Racket: "Shuffle" Polymorphic Function problem

2015-05-18 Thread Tim Brown
Folks, I'm trying to write a shuffle function in TR, composed of a "Cutter" function and a "Riffler" function. I start with a few types and implementations for a cutter and a riffler. The shuffler is basically (riffle (cut deck)): -- #lang

Re: [racket-users] Strange behaviour of the eq? operator in racket repl

2015-05-18 Thread Atticus
George Neuner writes: > Hi, > > On 5/17/2015 5:32 PM, Atticus wrote: >> --- >> $ racket >> Welcome to Racket v6.1.1. >> > (eq? 'l 'l) >> #f >> > (eq? 'l 'l) >> #t >> > >> >> $ racket --no-jit >> Welcome to Racket v6.1.1. >> > (eq? 'l 'l) >> #f >> > (eq? 'l 'l) >> #t >> > (