lexi-lambda changed the topic of #racket to: Racket v7.5 has been released: https://blog.racket-lang.org/2019/11/racket-v7-5.html -- Racket -- https://racket-lang.org -- https://pkgs.racket-lang.org -- Paste at http://pasterack.org
badkins has joined #racket
badkins has quit [Remote host closed the connection]
badkins has joined #racket
evdubs has quit [Quit: Leaving]
analogue has joined #racket
evdubs has joined #racket
endobson has joined #racket
pera has quit [Ping timeout: 268 seconds]
notzmv has joined #racket
badkins has quit [Remote host closed the connection]
analogue has quit [Quit: Leaving]
dddddd has quit [Read error: Connection reset by peer]
pera has joined #racket
k_sze has left #racket ["Leaving"]
pera has quit [Ping timeout: 272 seconds]
Sgeo__ has joined #racket
Sgeo_ has quit [Ping timeout: 268 seconds]
libertyprime has joined #racket
libertyprime has quit [Client Quit]
libertyprime has joined #racket
endobson has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
endobson has joined #racket
iyzsong has joined #racket
mzan has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
mzan has joined #racket
libertyprime has quit [Ping timeout: 240 seconds]
pera has joined #racket
libertyprime has joined #racket
orivej has joined #racket
Sgeo_ has joined #racket
Sgeo__ has quit [Ping timeout: 240 seconds]
endformationage has quit [Ping timeout: 272 seconds]
Sauvin has joined #racket
pera has quit [Ping timeout: 272 seconds]
narimiran has joined #racket
badkins has joined #racket
badkins has quit [Ping timeout: 272 seconds]
ZombieChicken has quit [Ping timeout: 268 seconds]
_whitelogger has joined #racket
endformationage has joined #racket
Sgeo has joined #racket
nullcone has quit [Quit: Connection closed for inactivity]
efm has joined #racket
Sgeo_ has joined #racket
nikoala has joined #racket
Sgeo has quit [Ping timeout: 272 seconds]
badkins has quit [Remote host closed the connection]
badkins has joined #racket
badkins has quit [Ping timeout: 240 seconds]
badkins has joined #racket
badkins has quit [Remote host closed the connection]
badkins has joined #racket
badkins has quit [Ping timeout: 240 seconds]
jellie has joined #racket
jellie has quit [Client Quit]
endobson has joined #racket
ArthurStrong has joined #racket
<ArthurStrong> Hi all. How to make a list consisting of n elements? I want (func 3 'asd) -> '('asd 'asd 'asd)
<bremner> rudybot: doc make-list
<rudybot> bremner: http://docs.racket-lang.org/reference/pairs.html#(def._((lib._racket%2Flist..rkt)._make-list))
badkins has joined #racket
<ArthurStrong> bremner: oh thanks
badkins has quit [Remote host closed the connection]
badkins has joined #racket
endobson has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
pera has joined #racket
badkins has quit [Ping timeout: 260 seconds]
endobson has joined #racket
endobson has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ZombieChicken has quit [Ping timeout: 260 seconds]
YuGiOhJCJ has joined #racket
badkins has joined #racket
efm has quit [Ping timeout: 272 seconds]
efm has joined #racket
ermo has quit [Ping timeout: 246 seconds]
ermo has joined #racket
teardown has quit [Ping timeout: 265 seconds]
nullcone has joined #racket
pera has quit [Quit: leaving]
aidalgol has joined #racket
lavaflow has quit [Ping timeout: 240 seconds]
ng0 has joined #racket
badkins has quit [Remote host closed the connection]
badkins has joined #racket
badkins has quit [Ping timeout: 256 seconds]
Sgeo__ has joined #racket
YuGiOhJCJ has quit [Quit: YuGiOhJCJ]
Sgeo_ has quit [Ping timeout: 256 seconds]
badkins has joined #racket
Fernando-Basso has quit [Quit: Leaving]
notzmv has quit [Ping timeout: 272 seconds]
badkins has quit [Remote host closed the connection]
badkins has joined #racket
pera has joined #racket
badkins has quit [Ping timeout: 268 seconds]
sauvin has quit [Read error: Connection reset by peer]
FreeFull has joined #racket
Boarders has joined #racket
<Boarders> in the racket documentation for match it gives an incorrect definition of length: https://docs.racket-lang.org/reference/match.html
<Boarders> I don't know how to link to a specific part of the documentation but it is where it has (define (len l)) ...
<Boarders> What does a correct version of using match to de-structure a list look like?
<Boarders> if that is something it is possible to do with match
<Boarders> I can't figure out how to use it in any example apart from a pattern match on literal values
<greghendershott> Boarders: There are many ways to use `list`, `list*`, `list-rest`, and `cons` as match patterns for lists, depending on what you want to do.
<Boarders> could you give a concrete example of such a thing?
<greghendershott> For example matching the first item and the rest (i.e. `car` and `cdr` or `first` and `rest`) could be any of these: `(cons this more)`. `(list* this more)`, `(list this more ...)`. All will bind `this` to the first item, and `more` to the rest.
<Boarders> what do you do for the nil case?
<greghendershott> Usually I just use `(list)` as the clause, before another clause that tries to destructure a non-empty list.
<greghendershott> I mean I use `(list)` as the pattern in a first clause. Then another clause using whatever, let's say `(list* this more)`, that would fail if the list were empty.
<greghendershott> Instead of `(list)` as the pattern for an empty list, you could use `'()` or `empty` or whatever.
<greghendershott> I usually tend to use the same style as for the other clauses.
<Boarders> hmm sorry for the thickheadedness but could you give an example of something akin to: (head lst (match lst ('() (error "ahh")) ((const hd tail) hd)))
<greghendershott> Oh right right you also have quasiquote patterns for lists. Like `(,this . ,more)`.
<Boarders> cons*
<Boarders> I'm not very proficient in racket or scheme so I am probably missing something completely obvious
<greghendershott> Yep, you almost have it there. Let me just fiddle for a second to make sure I have it right for you. :) ....
<Boarders> err I also forgot to write define etc
<greghendershott> Sorry the pasterack Google captcha slowed me down.
<greghendershott> Here you go.
<greghendershott> Boarders: http://pasterack.org/pastes/74811
<Boarders> ah perfect thank you!
<ArthurStrong> Probably dumb question. I want to use only one branch of IF. I have to add #f on other branch. But these #f's are dumping into output. What to do?
<ArthurStrong> Is there an one-branch IF?
<greghendershott> Boarders: And if you prefer quasiquote style patterns: http://pasterack.org/pastes/13481
<Boarders> btw @greghendershott: how should I think about that (list) pattern match?
<greghendershott> It's really a matter of taste.
<technomancy> ArthurStrong: maybe `when' would be better, if it's a side-effecting thing.
<ArthurStrong> technomancy: thakns for the idea
<greghendershott> The `(list)` pattern matches the same thing that a `(list)` expression evaluates to.
<ArthurStrong> Also, how to suppress #<void>'s? I'm calling a "void" function from for/list. And these void's clutters output
<greghendershott> The nice thing is that the match patterns mirror the syntax of how you would produce such a thing.
<greghendershott> So it has a very "by example" feel.
<technomancy> ArthurStrong: if that happens usually it means you are mixing side-effects and values
<technomancy> usually a sign you should restructure your code
<ArthurStrong> maybe...
<Boarders> oh I see, that makes sense
<Boarders> thank you for your help!
<greghendershott> Boarders: You're welcome. `match` can feel strange at first, and the docs show so many kinds of patterns. But it's a really beautiful thing when you get the hang of it.
<Boarders> I am coming from Haskell so I wanted to reach for pattern matches immediately, but as you say that document is a bit heavy :)
<ArthurStrong> I want to call a "void" function n times. Doing this by for/list. And #<void>'s clutter output. What should I do?
<Boarders> (I must also say that that linked paste-rack is a thing of beauty)
<technomancy> ArthurStrong: `for/list' is used to return a list. if you're calling a function that returns void, you shouldn't be returning a meaningful value. `for' would be better.
<Boarders> (as is your racket emacs mode :) )
<greghendershott> Boarders: Ah, cool. One thing to be aware of is that Racket `match` does not do exhaustiveness checking for you. If you don't cover some case, you'll drop off the end of the `match` and get a runtime error. So that's not as spiffy as Haskell, but otherwise I think they're similar.
<ArthurStrong> technomancy: oh, that solved everything. Thanks a lot
<greghendershott> Boarders: Oh thanks. I've been working pretty hard, last month, on making it buggier^W better. A preview not yet merged: https://www.racket-mode.com/racket-check-syntax-preview/
<technomancy> ArthurStrong: cool. mixing side-effects and logic is a really common beginner mistake for folks new to FP but you get the hang of it, and Racket usually gives you hints when you're doing stuff like that
<ArthurStrong> technomancy: by side-effects you mean I/O?
<technomancy> ArthurStrong: that's one way to put it, yeah
<Boarders> greghendershott: looks amazing :)
<technomancy> ArthurStrong: impure vs pure is maybe the clearest way
<technomancy> *clearest way to describe it
<greghendershott> Boarders: Thanks I just need to hire technomancy as a naming consultant. racket-check-syntax-mode is long and bad.
<greghendershott> technomancy is good at naming projects. :)
<ArthurStrong> technomancy: thanks
Boarders has quit [Remote host closed the connection]
Boarders has joined #racket
<ArthurStrong> BTW. What is better, let, let* or define? I'm stuck with the latter.
<ArthurStrong> And I'm satisfied with defines inside function
<ArthurStrong> So why using let then?
<greghendershott> ArthurStrong: One suggestion: https://docs.racket-lang.org/style/Choosing_the_Right_Construct.html#%28part._.Definitions%29
<ArthurStrong> greghendershott: thanks
<greghendershott> The audience for that is people developing Racket, but, you might find some ideas you like.
ng0 has quit [Ping timeout: 240 seconds]
nikoala has quit [Ping timeout: 240 seconds]
<ArthurStrong> Contracts are just confusing :( Can anyone point for some simple explanation for C/C++ programmer? I just want to assure that one function's argument is always a list of integers. As simple as this. And another arg is integer. Nothing else.
<ArthurStrong> Are they borrowed from another PL?
badkins has joined #racket
<ArthurStrong> Isn't it the same as Hoare triple?
badkins has quit [Ping timeout: 240 seconds]
badkins has joined #racket
<ArthurStrong> Am I right contract is like superset and generalization of assert()'s?
<ArthurStrong> Should I better start at (raise-argument-error)?
badkins has quit [Ping timeout: 260 seconds]
<greghendershott> ArthurStrong: Sure, you can think of contracts like automatic asserts for the arguments and return values of a function -- including when a function is used as an argument to another function, like say when using `map`.
<greghendershott> Have you seen this? https://docs.racket-lang.org/guide/contract-func.html
<greghendershott> I think that short section of the Guide might be the TL;DR you want?
<ArthurStrong> greghendershott: thanks!
<greghendershott> Contracts can do a lot of things, that you might not need to know now, or ever, but it's there if/when you hit the need.
<greghendershott> ArthurStrong: You might want to start with `define/contract`. That's where the contract is attached to the function.
<greghendershott> (You can also have the contract apply only to the function when it's provided and used by some other module.)
<greghendershott> There are pros and cons. My guess from where you're coming from, `define/contract` will make more sense, to start.
* greghendershott has to go AFK for awhile...
wreed has joined #racket
ArthurStrong has quit [Quit: leaving]
badkins has joined #racket
narimiran has quit [Quit: leaving]
Boarders has quit [Remote host closed the connection]
notzmv has joined #racket
Codaraxis has joined #racket
ng0 has joined #racket
Sgeo_ has joined #racket
Lowl3v3l has joined #racket
wreed has quit [Quit: Goodbye]
Sgeo__ has quit [Ping timeout: 260 seconds]
wreed has joined #racket
true-grue has quit [Read error: Connection reset by peer]
wreed has quit [Quit: Goodbye]
ZombieChicken has joined #racket
camelCaser has quit [Read error: Connection reset by peer]
Codaraxis has quit [Ping timeout: 268 seconds]
camelCaser has joined #racket
Codaraxis has joined #racket
Trieste has quit [Ping timeout: 240 seconds]
lavaflow has joined #racket
Trieste has joined #racket
Codaraxis has quit [Read error: Connection reset by peer]
badkins has quit [Remote host closed the connection]
efm has quit [Ping timeout: 240 seconds]
efm has joined #racket