Re: [racket-users] IO in racket is painful

2016-03-22 Thread Mark Engelberg
On Tue, Mar 22, 2016 at 9:20 PM, Stephen Chang wrote: > :) I had started writing up a parsack example, and I was all set to > admonish the OP for not creating a parser when you want a parser but > then I saw it was for a programming contest where I guess this sort of >

Re: [racket-users] IO in racket is painful

2016-03-22 Thread Stephen Chang
> It may be overkill for this use case, but I would probably use the > parsack package, since I think its interface is pretty intuitive. :) I had started writing up a parsack example, and I was all set to admonish the OP for not creating a parser when you want a parser but then I saw it was for a

Re: [racket-users] IO in racket is painful

2016-03-22 Thread Alexis King
Honestly, judging from the responses in this thread, it would seem there may be a hole in Racket’s toolbox. Nothing I’ve seen so far is particularly stellar, especially since this is a problem that does not seem like it should be hard. It may be overkill for this use case, but I would probably

Re: [racket-users] IO in racket is painful

2016-03-22 Thread Mark Engelberg
Hi, I have coached several teams on using Racket in programming contests. In our local contests, the most common input format is to have one line per dataset, and each dataset is typically several pieces of data separated by spaces. For this common input format, the 2htdp/batch-io teachpack is

Re: [racket-users] IO in racket is painful

2016-03-22 Thread WarGrey Gyoudmon Ju
On Wed, Mar 23, 2016 at 8:26 AM, WarGrey Gyoudmon Ju wrote: > In Racket, (read) and (write) know all the builtin datatypes > > which > are already structured more than a stream of

Re: [racket-users] IO in racket is painful

2016-03-22 Thread WarGrey Gyoudmon Ju
In Racket, (read) and (write) know all the builtin datatypes which are already structured more than a stream of bytes (like in C). Thus, you don't need scanf to tell Racket what is the type of the next token.

Re: [racket-users] IO in racket is painful

2016-03-22 Thread Stephen Chang
A "read" variant that works with format strings would be a useful addition I think. Matthew, your solution is clever :) (but with symbols instead of strings). Another alternative could be to use match: #lang racket (define (trim-brackets str) (string-trim str #rx"\\[|\\]|,")) (define (pad n

Re: [racket-users] IO in racket is painful

2016-03-22 Thread Matthew Butterick
> Then, for all rows, read and split the string. The best that i have found to > do that is using regular expressions. > > (define split-row (regexp-match #rx"\\[(.+), (.+), (.+)\\]" (read-line))) > > Then you have to manually convert the substrings into values > > (define a

[racket-users] IO in racket is painful

2016-03-22 Thread rom cgb
Hi, I recently started using Racket and i couldn't find a good alternative to C's scanf/printf in the racket standard library. When doing programming challenges, you often need to comply to a specific input/ouput thus having something like scanf for string to values and printf for values to

RE: [racket-users] submodule order dependency

2016-03-22 Thread Jos Koot
Hi Matthias, Thanks, I did see that part of the docs, but overlooked the word "preceding". Apologies for my noise. On second thought, I agree with the choice of order, because comparing with 'define' (in a non-lazy language) we can't allow: (define b a) (define a 'whatever) So indeed, the choice

Re: [racket-users] submodule order dependency

2016-03-22 Thread Matthias Felleisen
On Mar 22, 2016, at 8:47 AM, Jos Koot wrote: > The following works in the definitions window of DrRacket: > > #lang racket > (module a racket (display 'dog)) > (module b racket (require (submod ".." a))) > (require 'b) > > Display 'dog' when run. > > But reversing the

[racket-users] [TFPIE 2016] 2nd call for papers

2016-03-22 Thread p.achten
Trends in Functional Programming in Education (TFPIE 2016) 2nd Call for papers https://wiki.science.ru.nl/tfpie/TFPIE2016 The 5th International Workshop on Trends in Functional Programming in Education, TFPIE 2016, will be held on June 7, 2016 at the

[racket-users] submodule order dependency

2016-03-22 Thread Jos Koot
The following works in the definitions window of DrRacket: #lang racket (module a racket (display 'dog)) (module b racket (require (submod ".." a))) (require 'b) Display 'dog' when run. But reversing the order of the submodules a and b does not work: #lang racket (module b racket (require

Re: [racket-users] Can a macro have an affect above/outside its scope?

2016-03-22 Thread Hendrik Boom
On Mon, Mar 21, 2016 at 08:37:57AM -0700, Brian Adkins wrote: > On Monday, March 21, 2016 at 11:19:18 AM UTC-4, Neil Van Dyke wrote: > > I propose that it's time for `#lang racket/base` to have a `define/provide`. > > > > (Out of all the possible combinations of definition forms and other > >