TCZ has joined #racket
catonano has quit [Ping timeout: 260 seconds]
bitmapper has quit [Ping timeout: 246 seconds]
nan` has quit [Ping timeout: 246 seconds]
badkins has quit [Remote host closed the connection]
badkins has joined #racket
badkins has quit [Remote host closed the connection]
badkins_ has joined #racket
pilne_ has joined #racket
pilne has quit [Ping timeout: 246 seconds]
pilne_ has quit [Ping timeout: 260 seconds]
Sgeo__ has joined #racket
Sgeo_ has quit [Ping timeout: 260 seconds]
nan` has joined #racket
teardown has quit [Ping timeout: 256 seconds]
TCZ has quit [Quit: Leaving]
orivej has quit [Ping timeout: 240 seconds]
nan` has quit [Ping timeout: 260 seconds]
YuGiOhJCJ has joined #racket
badkins_ has quit [Remote host closed the connection]
badkins has joined #racket
badkins has quit [Ping timeout: 264 seconds]
endformationage has quit [Quit: WeeChat 2.6]
KDr2 has joined #racket
KDr24 has quit [Ping timeout: 246 seconds]
SGASAU has quit [Remote host closed the connection]
SGASAU has joined #racket
nan` has joined #racket
narimiran has joined #racket
dddddd has quit [Ping timeout: 258 seconds]
brainacid has joined #racket
<
brainacid>
im surprised no racket-mode for emacs
brainacid has quit [Quit: Lost terminal]
brainacid has joined #racket
SGASAU has quit [Remote host closed the connection]
SGASAU has joined #racket
<
aeth>
M-x package-list-packages RET C-s racket-mode
<
aeth>
I see it, if you don't, you might not have melpa
PlasmaStrike has quit [Ping timeout: 252 seconds]
catonano has joined #racket
<
brainacid>
had to refresh first
<
brainacid>
thanks aeth
<
brainacid>
i appreciate the verbose response
<
brainacid>
im such a newb
SGASAU has quit [Remote host closed the connection]
SGASAU has joined #racket
aidalgol has quit [Remote host closed the connection]
nan` has quit [Ping timeout: 246 seconds]
tilpner has quit [Quit: tilpner]
aidalgol has joined #racket
brainacid has quit [Quit: Lost terminal]
SGASAU has quit [Remote host closed the connection]
SGASAU has joined #racket
SGASAU has quit [Read error: Connection reset by peer]
SGASAU has joined #racket
SGASAU has quit [Remote host closed the connection]
SGASAU has joined #racket
narimiran has quit [Ping timeout: 264 seconds]
rgherdt_ has joined #racket
catonano has quit [Quit: catonano]
rgherdt has quit [Ping timeout: 265 seconds]
orivej has joined #racket
narimiran has joined #racket
Sgeo_ has joined #racket
Sgeo__ has quit [Ping timeout: 264 seconds]
gaqwas has joined #racket
nullcone has quit [Quit: Connection closed for inactivity]
Fare has quit [Quit: Leaving]
TCZ has joined #racket
SGASAU has quit [Remote host closed the connection]
SGASAU has joined #racket
gaqwas has quit [Read error: Connection reset by peer]
gaqwas has joined #racket
iyzsong has joined #racket
SGASAU has quit [Ping timeout: 260 seconds]
rgherdt has joined #racket
dddddd has joined #racket
lavaflow has quit [Ping timeout: 256 seconds]
bremner has quit [Quit: Coyote finally caught me]
catonano has joined #racket
TCZ has quit [Quit: Leaving]
iyzsong has quit [Ping timeout: 265 seconds]
badkins has joined #racket
nisstyre has quit [Quit: WeeChat 2.7]
nisstyre has joined #racket
badkins has quit [Remote host closed the connection]
TCZ has joined #racket
badkins has joined #racket
cantstanya has quit [Remote host closed the connection]
cantstanya has joined #racket
SGASAU has joined #racket
efm has joined #racket
Sgeo__ has joined #racket
bitmapper has joined #racket
Sgeo_ has quit [Ping timeout: 258 seconds]
SGASAU has quit [Ping timeout: 256 seconds]
nan` has joined #racket
cpup has quit [Quit: Breaking stuff]
cpup has joined #racket
rgherdt_ has quit [Remote host closed the connection]
lavaflow has joined #racket
gaqwas has quit [Quit: Leaving]
TCZ has quit [Quit: Leaving]
true-grue has joined #racket
YuGiOhJCJ has quit [Quit: YuGiOhJCJ]
<
samth>
narimiran: what is it that you're trying to do?
<
narimiran>
samth: exactly what this function does ;) e.g. transform '(1 2 3 4 5) into '(1 3 6 10 15)
<
samth>
so, prefix sums?
<
samth>
This will work: `(for/list ([i (length l)]) (apply + (take l i)))`
<
samth>
rudybot: init racket/base
<
rudybot>
samth: your racket/base sandbox is ready
<
samth>
rudybot: (define l '(1 2 3 4 5) )
<
rudybot>
samth: Done.
<
samth>
rudybot: (for/list ([i (length l)]) (apply + (take l i)))
<
rudybot>
samth: error: take: undefined; <NEWLINE> cannot reference an identifier before its definition <NEWLINE> in module: 'program
<
samth>
rudybot: (require racket/list)
<
rudybot>
samth: Done.
<
samth>
rudybot: (for/list ([i (length l)]) (apply + (take l i)))
<
rudybot>
samth: ; Value: '(0 1 3 6 10)
<
narimiran>
(btw, i always forget there's `take` for lists!)
SGASAU has joined #racket
<
narimiran>
samth: thanks for the idea, let me try it myself :)
<
samth>
that's not so efficient so you can replace `(apply + (take l i))` with something better
<
samth>
if you want to avoid the extra traversal for `length`, you can do it more directly with recursion, but that's probably unnecessary
<
narimiran>
samth: and what about my version? is it okay or would you avoid writing it like that (if so: why)?
<
samth>
it seems fine
<
samth>
i might write it with two accumulators, one for the sum-so-far
<
narimiran>
btw, when you have two accumulator, how do you pick/return just one of them?
<
narimiran>
and what would be the second accumulator for?
<
samth>
one for the sum, one for the list
<
samth>
but it might be easier to just write a recursive function
<
samth>
(let loop ([l l] [sum 0]) (if (null? l) null (cons (+ sum (car l)) (loop (cdr l) (+ sum (car l))))))
<
narimiran>
thanks!
catonano has quit [Quit: catonano]
emacsomancer has quit [Read error: Connection reset by peer]
catonano has joined #racket
cpup has quit [Quit: Breaking stuff]
badkins has quit [Remote host closed the connection]
badkins has joined #racket
emacsomancer has joined #racket
badkins has quit [Ping timeout: 246 seconds]
SGASAU has quit [Ping timeout: 256 seconds]
badkins has joined #racket
SGASAU has joined #racket
efm has quit [Ping timeout: 244 seconds]
efm has joined #racket
nullcone has joined #racket
Lowl3v3l has joined #racket
Lowl3v3l has quit [Quit: Leaving.]
Lowl3v3l has joined #racket
Lowl3v3l has quit [Remote host closed the connection]
Lowl3v3l has joined #racket
badkins has quit [Remote host closed the connection]
badkins has joined #racket
badkins has quit [Ping timeout: 260 seconds]
badkins has joined #racket
efm has quit [Read error: Connection reset by peer]
narimiran has quit [Quit: leaving]
efm has joined #racket
casaca has quit [Quit: leaving]
SGASAU has quit [Remote host closed the connection]
SGASAU has joined #racket
casaca has joined #racket
SGASAU has quit [Ping timeout: 260 seconds]
casaca has quit [Quit: leaving]
casaca has joined #racket
rgherdt has quit [Quit: Leaving]
nullcone has quit [Quit: Connection closed for inactivity]
SGASAU has joined #racket
emacsomancer has quit [Read error: Connection reset by peer]
nan`_ has joined #racket
emacsomancer has joined #racket
nan` has quit [Ping timeout: 260 seconds]
SGASAU has quit [Remote host closed the connection]
SGASAU has joined #racket
dvdmuckle has quit [Quit: Bouncer Surgery]
dvdmuckle has joined #racket
SGASAU has quit [Remote host closed the connection]
SGASAU has joined #racket
TCZ has joined #racket
cantstanya has quit [Remote host closed the connection]
SGASAU has quit [Remote host closed the connection]
true-grue has quit [Read error: Connection reset by peer]
SGASAU has joined #racket
cantstanya has joined #racket
SGASAU has quit [Remote host closed the connection]
SGASAU has joined #racket
TCZ has quit [Quit: Leaving]
badkins has quit [Remote host closed the connection]
badkins has joined #racket
TCZ has joined #racket
juanfra has quit [Quit: juanfra]
juanfra has joined #racket
badkins has quit [Ping timeout: 260 seconds]
selimcan has joined #racket
badkins has joined #racket
nullcone has joined #racket
selimcan has quit [Quit: Leaving]