thx!
@spdegabrielle thx sofar. I like it. I was wondering also when Creating a new github repository, I cannot select the language racket
I was wondering how we could contact somehow GitHub and say to add racket
to a template. normally selecting racket lang template, it should add a usefull gitignore things etc.
@darioszr github guesses the language from the source files. You can set the topic to ‘racket’ https://help.github.com/en/articles/classifying-your-repository-with-topics
@spdegabrielle right thx! what I was stating is that currenlty we don’t have a gitignore
in Racket
I don’t know if it is usefull
(I’m still a nob for that :grin:) like when I create a new repo, i can select clojure, go, python bu tthere isn’t a racket gitignore.. that is what I was meaning. But for moment I don’t know if it is useful or not
@darioszr raco pkg new
creates a racket-specific .gitignore
ok thx!
does the #f
symbol have a meaning in racket?
It’s short for false.
I think #false works too (not completely sure)
ok so #t
is true then i assume
Yep.
thx!
I was thinking another obscure thing :grin:
Variable names can’t start with a #, so that’s why names of special values begin with #.
I’m reading this guide : https://docs.racket-lang.org/guide/ :clap: it is really good written
btw the foldl
function seems to me really similar to the clojure transduce
one https://clojure.github.io/clojure/clojure.core-api.html#clojure.core/transduce
If you haven’t seen the connection between fold and lists, then check: https://stackoverflow.com/questions/42144068/how-do-foldl-and-foldr-work-broken-down-in-an-example/42145203#42145203
And you are right, it is the same idea.
thx @soegaard2 ! I really enjoy racketlang sofar :four_leaf_clover:
I can’t wait to get more hands dirty :grin:
I mean they could have also just provided true
and false
variables from racket/base
They do in racket/bool, but I can’t remember whether it is in both racket/base and racket or only the latter.
But #t and #f can’t be shadowed.
nob question, are racketlang Places
the equivalent to Tony Hoare’s “communicating sequential processes” ?
so simplifying, are they similar to core.async and golang channels?
I have just saw them quickly through the doc, and they looks pretty the implementation to me, unless I’m overlooking things :grin:
Racket threads and channels might compare.
Threads are used all over, since they are easy to use.
They are concurrent, but all threads run on the same cpu - so they are not running in parallel.
might compare -> do compare
thx!
In Racket terminology, “places” are for OS-level parallelism—a place is a CPU thread—and “threads” are green threads for concurrency without parallelism. Both share the same model of concurrency, which is most closely related to Concurrent ML: it is definitely inspired by “communicating sequential processes”. Andy Wingo, who implemented a similar system for Guile Scheme, has some blog posts comparing them to Go and core.async
, e.g. https://wingolog.org/archives/2016/10/12/an-incomplete-history-of-language-facilities-for-concurrency
Thx Philip for this accurate answer:heart: :heart: :racket:
Could I get some advice on a function I’m trying to write please? The goal is to convert Racket numerical expressions to Forth expressions/statements: '(+ a (* b (- c d) e) f)
=>
'(a b c d - e * * f + +)
The first challenge being that Racket is prefix, and Forth is postfix. The second challenge being that Racket numerical operators can take a variable number of arguments whereas Forth numerical operators (binary ones, that is) take a fixed number of two, with the stack holding intermediate results.
Another concern is that there doesn’t seem to be strict a 1-to–1 mapping between the conversions. That is, you can rearrange the expression in several ways and still get the same answer.
Could anyone please suggest how I could go about doing this, which individual functions I should try and write before combining them together, which conversion-format/order is simpler and such? Thanks :) I’ve tried various combinations of reversing but I feel like I’m just throwing things too see which stick, as I can’t seem to come up with a well-defined plan of action on how to tackle the problem. My brain really seems to have a thing about nested lists that makes it fall to pieces :/
@sydney.lambda I actually did exactly this the other week. You want the Shunting-Yard Algorithm https://en.m.wikipedia.org/wiki/Shunting-yard_algorithm
Oh wait nevermind, that’s for going from infix to forth. So to use that algorithm you’d need a first pass in front that goes from prefix to infix.
thanks for the link @notjack :) I’m sure I can learn something from looking at that algorithm even if it’s not a direct conversion.
thanks to Beautiful Racket, I think I have the varargs->binary part covered! :) (define (forthify ls)
(match ls
[`(+ ,x) (list x)]
[`(+ ,x ,xs ...) (append `(+ ,x)
(forthify `(+ ,@xs)))]))
(forthify '(+ 1 2 3 4 5))
=> '(+ 1 + 2 + 3 + 4 5)
=> '(5 4 + 3 + 2 + 1 +) ;reversed
However, I’d like to eventually be able to convert any Racket expression into this form, which would have to respect the order of bindings and thus require a transformation like: (forthify '(+ 1 2 3 4 5))
=> '(1 2 + 3 4 + 5 + +)
any advice on how to I can achieve this? Thanks :)
May I be nosy and ask what the project was? If it was part of a project, of course.
I was working on a transducers library for Rebellion*, to complement reducers**. And a friend told me about this algorithm and I thought it was super cool that it’s single-pass and uses only a small amount of memory for a stack. So I made a transducer that implements the algorithm, giving me a streaming and memory-efficient implementation capable of parsing sequences that are too long to keep in memory all at once. It was a fun proof-of-concept problem for transducers.
I tweeted about the implementation a little too: https://twitter.com/doitwithalambda/status/1157942169547575296