<ym555>
oh whoops replace "whatever" with "parameters" in my sentence
sebastianlin has quit [Ping timeout: 256 seconds]
<NeoHamled>
Is empty considered more idiomatic Racket than '()?
<NeoHamled>
Ruby, always helpful with a variety of options, allows for [], Array.new, and even nil.to_a but I believe [] is considered the idiomatic way to write it
lockywolf has quit [Read error: Connection reset by peer]
lockywolf_ has joined #racket
lockywolf_ has quit [Ping timeout: 264 seconds]
pie__ has joined #racket
pie___ has quit [Ping timeout: 245 seconds]
<lexi-lambda>
NeoHamled: I think '() is significantly more common in Racket code than empty.
<NeoHamled>
Okay thanks
selimcan has joined #racket
FreeFull has quit []
lockywolf has joined #racket
Lowl3v3l has quit [Remote host closed the connection]
lockywolf has quit [Max SendQ exceeded]
ym555 has quit [Ping timeout: 246 seconds]
selimcan has quit [Remote host closed the connection]
fridim has quit [Ping timeout: 252 seconds]
fridim has joined #racket
endformationage has quit [Quit: WeeChat 2.3]
pierpal has quit [Quit: Poof]
pierpal has joined #racket
iclon has quit [Ping timeout: 244 seconds]
iclon has joined #racket
sebastianlin has joined #racket
iclon has quit [Ping timeout: 255 seconds]
iclon has joined #racket
orivej has quit [Ping timeout: 240 seconds]
sauvin has joined #racket
pera has quit [Ping timeout: 258 seconds]
pierpal has quit [Ping timeout: 246 seconds]
pierpal has joined #racket
orivej has joined #racket
dmiles has quit [Ping timeout: 255 seconds]
widp_ has joined #racket
Falacer has joined #racket
YuGiOhJCJ has joined #racket
dmiles has joined #racket
cantstanya has quit [Remote host closed the connection]
<keep_learning_M>
is not possible "cannot reference an identifier before its definition"
<keep_learning_M>
Now my question is how can we achieve this kind of constraint of data structure which takes some base type (int, bool) or it self (recursively defined) ?
<keep_learning_M>
Please leave your message in gist. Thank you very much in advance.
eush has joined #racket
YuGiOhJCJ has quit [Quit: YuGiOhJCJ]
pierpal has quit [Quit: Poof]
pierpal has joined #racket
Lowl3v3l has joined #racket
m4110c has joined #racket
<m4110c>
Hi all, I have a little problem and can't find a solution. My problem is, that I have a list of numbers and I wannt to add them all up and calculate the average of them, recursively. So if I had (list 3 6 9), I would calculate the sum, which is 18 and divide by the length of the list which is 3. But on every recursion step the length of the list decreases and I have no "counter" or so to keep track of the
<m4110c>
initial length of the list. I'd really appreciate any hint in the right direction
<pierpal>
make the recursion step such that you have the lenght of the list examined so far.
<m4110c>
The recursion step would be the else clause right?
<eush>
m4110c: you don't need to pass the original length, at each step you just need to (1) compute the sum and (2) divide it by the number of students (length students)
<eush>
m4110c: in order to compute (1) you add up the age of (first student) to the (* (length (rest students)) (mean-of-ages (rest students)))
<m4110c>
eush: but where in the code do I put the division. Because if I put it in the else clause, it gets evaulated on every recurstion step
<m4110c>
and in each step the length is one less than the time before
<eush>
m4110c: if you want to do the division once, why not split it into a recursive function that calculates the sum, and call it from a non-recursive functions that calculates means?
<m4110c>
eush: yes, that would be one solution. using a helper function. but I wanted to try without. It's just to help my understanding and play around.
<eush>
m4110c: well, you can also add the counter parameter to your function, and increment it on each recursive step
<m4110c>
I wonder if there is no "mathematical" way to solve it within one function. Like adding something to the sum on each step and dividing at the end... something dependent on the length of the initial list or so. Don't know if I express myself clearly :-D
<m4110c>
Ok, I'll try more and maybe get back to you guys. Thanks for the input so far
<eush>
m4110c: there certainly is a mathematical way to derive the mean of a list from the mean of the sublist
pierpal has quit [Quit: Poof]
pierpal has joined #racket
<eush>
m4110c: if your function returns the mean of a list, then each recusion invocation has to have a division in there, so in the end you will perform the division multiple times - i guess there's no getting around this constraint with one function
<m4110c>
yes. let's say the length is n. On every step it becomes n-1. I need to go on from there somehow
<m4110c>
Multiplying or dividing with regard to n on each step and then at the end doing something (which I don't know yet)
q9929t has quit [Remote host closed the connection]
<m4110c>
I multiply (the length of the list - 1) to every recursion step and divide by (the length of the list) at the end
widp_ has quit [Ping timeout: 268 seconds]
q9929t has joined #racket
<eush>
m4110c: you ended up with my suggestion :)
<m4110c>
eush: yep. just the concrete implementation was missing. I had a feeling, that it works mathematically by dividing multiple times. just did not know where exactly in the code to put it.
<m4110c>
I'm not even sure, that I understand it completely, yet. Need to look at it more.
<m4110c>
Thanks for you help! Really great channel here
<m4110c>
Is there something like a "racket visualiser" that lays out the recursive functions to see the full execution path?
widp_ has joined #racket
m4110c has quit [Quit: m4110c]
ym555 has joined #racket
lavaflow_ has quit [Ping timeout: 250 seconds]
dbmikus_ has joined #racket
jcowan has joined #racket
q9929t has quit [Quit: q9929t]
endformationage has joined #racket
sleepnap has joined #racket
pera has joined #racket
jonh has joined #racket
eush has quit [Quit: ERC (IRC client for Emacs 26.0.50)]
sleepnap has quit [Ping timeout: 252 seconds]
ym555 has quit [Ping timeout: 268 seconds]
sleepnap has joined #racket
selimcan has joined #racket
Falacer has quit [Remote host closed the connection]
selimcan has quit [Remote host closed the connection]
dbmikus_ has quit [Ping timeout: 245 seconds]
FreeFull has joined #racket
q9929t has joined #racket
ym555 has joined #racket
ng0 has quit [Quit: Alexa, when is the end of world?]
lavaflow_ has joined #racket
<bremner>
rudybot: later tell m4110 it's not graphical, but you might like trace
<rudybot>
bremner: I asked `MemoServ' to forward the message to m4110.
ng0 has joined #racket
dbmikus_ has joined #racket
pera has quit [Ping timeout: 255 seconds]
casmajavi has joined #racket
sauvin has quit [Read error: Connection reset by peer]
ng0 has quit [Remote host closed the connection]
ng0 has joined #racket
pera has joined #racket
dan_f has joined #racket
pera has quit [Ping timeout: 268 seconds]
q9929t has quit [Quit: q9929t]
dan_f has quit [Quit: dan_f]
ubLIX has joined #racket
ismay has joined #racket
pera has joined #racket
Fernando-Basso has joined #racket
orivej has quit [Ping timeout: 246 seconds]
dan_f has joined #racket
casmajavi has left #racket ["ERC (IRC client for Emacs 24.5.1)"]
dan_f has quit [Quit: dan_f]
dan_f has joined #racket
dan_f has quit [Client Quit]
dbmikus_ has quit [Ping timeout: 250 seconds]
dan_f has joined #racket
dan_f has quit [Quit: dan_f]
dbmikus_ has joined #racket
endformationage has quit [Ping timeout: 255 seconds]
dbmikus_ has quit [Ping timeout: 250 seconds]
acarrico has joined #racket
Fernando-Basso has quit [Remote host closed the connection]
ismay has quit [Quit: Using Circe, the loveliest of all IRC clients]