<aeth>
Guile has had a bit of a Renaissance in recent years.
<johnjay_>
would racket be "cleaner" since it is intended for educational stuff?
<johnjay_>
ah ok
<nisstyre>
not sure what cleaner is supposed to mean
<nisstyre>
I find the library naming conventions make more sense in Racket though
<aeth>
johnjay_: Racket is academic. It has the two goals that higher education in general has: teaching and research.
<aeth>
At least, that's my impression of Racket.
<johnjay_>
well gnu code doesn't have the reputation of being the most concise and uncluttered
<aeth>
Probably because GNU has a lot of the oldest projects
<johnjay_>
right
<johnjay_>
anyway that's cool if that's all ya go
<johnjay_>
t
<johnjay_>
i've used racket a little but didn't know guile was active
<aeth>
People didn't know how to write readable code back in the old days, or wrote code intentionally unreadable so it would run very slightly faster.
<aeth>
Not saying that Guile or things written in Guile are like that, but lots of stuff from the 1980s are.
<aeth>
(Guile's from 1993)
<johnjay_>
ok
<johnjay_>
is racket dev mainly on the github or on a mailing list?
<nisstyre>
johnjay_: if you want to contribute then github is the place
<nisstyre>
at least in my experience
<johnjay_>
ok. some projects just use github as a mirror
<nisstyre>
I think the mailing list is for more in-depth discussion
<hjek>
=> is like anaphoric macros!: "The proc-expr is evaluated, and it must produce a procedure that accepts one argument, otherwise the exn:fail:contract exception is raised. The procedure is applied to the result of test-expr in tail position with respect to the cond expression."
<hjek>
what a great idea. thanks for that soegaard
<soegaard>
Apropos match:
<soegaard>
(match 42
<soegaard>
[(and (? even?) x) (~a x " is even")]
<soegaard>
[x (~a x " is not even")])
<hjek>
~a ???
<hjek>
is that "format"?
<soegaard>
Yes, a convenient short form of format.
<hjek>
Yes, because sometimes it just *is* less verbose to use Common Lisp-style control structures. Looks good. You made that library?
<soegaard>
Yeah - but I don't use it.
<soegaard>
Great way to learn about macros though.
<hjek>
Thanks for all that. Racket has really good libraries, but I just find that writing pure Scheme-style Racket code is a bit draining, and I have some web app stuff I just need to get done for a customer. That pattern matching stuff and cond's => look really interesting.
iyzsong has quit [Ping timeout: 260 seconds]
<soegaard>
match is definitely worth investigating
<soegaard>
note that you as an user can extend match with your patterns
<hjek>
?
<soegaard>
your patterns -> your own patters
<soegaard>
The pattern (list a b) is builtin and matches a list with two elements.
<soegaard>
If you define your own data structure, say a table and representes in some way,
<soegaard>
then you can define a pattern (table a b) that matches tables consisting of two elements.
<hjek>
they do match on a struct, like this: [(struct binding:file (field filename headers content))
<hjek>
basically to check if there's a file being uploaded, i think
<hjek>
the match from line 25 onwards
<soegaard>
The pattern (struct binding:form (field value)) can also be written (binding:form field value)
<soegaard>
I think the old match implementation used an explicit (struct ...) and the new implementation allows both types of patterns.
<hjek>
nice
<hjek>
looks somewhat similar to what Java is doing with overloading, except just more powerful/flexible/well though out. thanks for pointing me to those things. Also, those Alexander Knauth libraries look interesting (although I'll probably be staying mostly with built-in language features for what I'm working on now)
soegaard has quit [Quit: soegaard]
hjek has quit [Ping timeout: 252 seconds]
mzan has left #racket [#racket]
zv has quit [Ping timeout: 276 seconds]
zv has joined #racket
ziyourenxiang has quit [Ping timeout: 268 seconds]
johnjay_ has quit [Ping timeout: 256 seconds]
dan_f has joined #racket
dan_f has quit [Quit: dan_f]
soegaard has joined #racket
phf_f334 has joined #racket
<phf_f334>
Hello!
<phf_f334>
Why would this work but not that?
<phf_f334>
where: this = `(require (file "/home/phf/tools/websites/blog/content/generated/compiler/src/config.rkt"))`
<phf_f334>
that = `(require (file (some-system-path->string (build-path "/home/phf/tools/websites/blog/content/generated/compiler/src/config.rkt"))))`
<phf_f334>
Thanks!
<soegaard>
because the here in (require here) is not an expressions (and require is not a function)
<phf_f334>
Ok, will check that. Thank you very much!
<phf_f334>
ROFL: "source_to_org: broke its own contract" :-)
pera has joined #racket
soegaard has quit [Quit: soegaard]
odanoburu has joined #racket
Lowl3v3l has joined #racket
mejja has joined #racket
soegaard has joined #racket
YuGiOhJCJ has joined #racket
sleepnap has joined #racket
soegaard has quit [Quit: soegaard]
mejja has left #racket [#racket]
soegaard has joined #racket
soegaard has quit [Quit: soegaard]
soegaard has joined #racket
soegaard has quit [Client Quit]
dmiles has quit [Ping timeout: 252 seconds]
logicmoo has joined #racket
sagax has quit [Ping timeout: 252 seconds]
soegaard has joined #racket
dyl has joined #racket
<dyl>
Perhaps a silly question, but what's the 'idiomatic' way to write a function or macro that takes a function f, and generates n successive applications of it?
<dyl>
i.e. (iterate f 3) ⇒ (lambda (x) (f (f (f x))))
<dyl>
(preferably as a macro)
<soegaard>
I have a feeling there is a function somewhere ...
<soegaard>
But for/fold can be used.
<dyl>
As do I, but I'm not sure what it's called here.
<soegaard>
(define (double x) (* 2 x))
<soegaard>
(for/fold ([x 1]) ([i 3]) (double x))
<dyl>
Well, one issue here is that for/fold is not a function I have access to :). I'm in a restricted subset the language.
<dyl>
So, I really want a macro and not a HOF.
<dyl>
The use case here, more or less, is that I'm generating program sketches for Rosette, and I want to be able to generate n-depth ASTs.
<soegaard>
Then it might be simpler to implement it your self.
<dyl>
So, in the above what I actually want is the suspended form '(lambda (x) (f (f (f x)))
<dyl>
Yeah, I'm just not sure how to do that.
<dyl>
The names in racket are all different than those I'm used to in the Ocaml/Haskell worlds.
<soegaard>
The simple case: (iterate f 0) => (lambda (x) x)
<soegaard>
How can (iterate f n) be written in terms of (iterate f (- n 1)) ?
<dyl>
Yes, I get how to write it inductively in the general case, just not with macros.
<dyl>
Or well, with racket's macros anyhow.
<soegaard>
There is no advantage of using macros here.
<dyl>
Sure, but I'd like to know how to do it.
<soegaard>
How would you do it in Haskell?
<dyl>
Haskell doesn't have macros.
<soegaard>
How would you do it in Haskell with functions?
<dyl>
That's not directly applicable here, as the standard formulation using `iterate` is non-strict and generates a stream.
<dyl>
I know how I would implement a simple function here.
<dyl>
Btu that's not my question.
<soegaard>
How about:
<soegaard>
(define (iterate f n)
<soegaard>
(λ (x)
<soegaard>
(let loop ([i n] [x x])
<soegaard>
(if (= i 0)
<soegaard>
x
<soegaard>
(loop (- i 1) (f x))))))
<soegaard>
Or perhaps:
<soegaard>
(define (iterate f n)
<soegaard>
(if (= n 0)
<soegaard>
(λ (x) x)
<soegaard>
(let ([g (iterate f (- n 1))])
<soegaard>
(λ (x)
<soegaard>
(g (f x))))))
<dyl>
Those are both way more complex than necessary?
<dyl>
(define (iterate f n)
<dyl>
[else (f (iterate f (- n 1)))]))
<dyl>
(cond [(= n 1) (f x)]
<rain2>
whats your question?
<dyl>
I was wondering how one would write a macro that expands to n successive nestings of a function.
<rain2>
i would have to use syntax-case I think. syntax-rules wouldn't be able to deal with a number
<dyl>
I'm completely unfamiliar with the racket macro system.
<dyl>
:p
<rain2>
let me paste you something related, so you can adapt it
<dyl>
Great!
<soegaard>
You did write "function or macro" in your original question... which explains why I wanted to show you a function solution.
<dyl>
I just wanted to see an example of how such a recursive macro w/ numbers would work.
<rain2>
so here's a macro that expands (make-list 3 'e) into (list 'e 'e 'e)
<pharpend_>
Hi everyone. I'm going through one of the beautiful-racket tutorials (specifically https://beautifulracket.com/bf/a-functional-expander.html), and running the tests on the bf code produce an error (I will bpaste one second)