bubblegum has quit [Read error: Connection reset by peer]
bubblegum has joined #racket
bubblegum has quit [Ping timeout: 260 seconds]
bubblegum has joined #racket
bubblegum has quit [Read error: Connection reset by peer]
bubblegum has joined #racket
bubblegum has quit [Read error: Connection reset by peer]
bubblegum has joined #racket
bubblegum has quit [Ping timeout: 252 seconds]
bubblegum has joined #racket
bubblegum has quit [Read error: Connection reset by peer]
bubblegum has joined #racket
bubblegum has quit [Read error: Connection reset by peer]
bubblegum has joined #racket
bubblegum has quit [Ping timeout: 272 seconds]
bubblegum has joined #racket
bubblegum has quit [Read error: Connection reset by peer]
bubblegum has joined #racket
bubblegum has quit [Read error: Connection reset by peer]
bubblegum has joined #racket
bubblegum has quit [Ping timeout: 268 seconds]
bubblegum has joined #racket
ormaaj has quit [Quit: kernel++]
<polarian>
question about vectors and lists... do the same rules apply as with other languages, vectors are stored in contiguous memory and when interated they are simply offsetted from the initial position of the vector. As for lists (which can be represented in cons pairs), each element is allocated separately and contains a pointer to the next element?
<polarian>
(how they work under the hood that is)
<polarian>
therefore vectors are faster to iterate than lists?
<shawnw>
Correct.
bubblegum has quit [Read error: Connection reset by peer]
bubblegum has quit [Read error: Connection reset by peer]
bubblegum has joined #racket
bubblegum has quit [Ping timeout: 246 seconds]
bubblegum has joined #racket
szkl has quit [Quit: Connection closed for inactivity]
ormaaj has joined #racket
to-hu has quit [Remote host closed the connection]
to-hu1 is now known as to-hu
to-hu has quit [Remote host closed the connection]
morte has quit [Ping timeout: 264 seconds]
morte has joined #racket
psilotorp has quit [Quit: Client closed]
<polarian>
I spoke to my professor and she said lists should always be done recursively
<polarian>
but recursive adds a stack frame per iteration
<polarian>
duplicates the variables passed in, and then repeats
<polarian>
until the break condition is met... and then pops backwards with the return result until the original call is returned
<polarian>
for/list exists, why would you recurse?
<polarian>
*I'm aware recursion is useful for transversal and path finding*
<samth>
for/list is implemented with recursion
<polarian>
oh...
<polarian>
so recursion is required for lists... why?
<polarian>
why can't it be done like other programming languages... I assume its due to how lists are structured in racket?
morte has quit [Remote host closed the connection]
<shawnw>
A lot of list iteration is done with tail recursive constructs which get turned into effectively iterative loops. Plus for non-tail recursion Racket allocates stack frames on the heat so you don't get stack overflows. See https://docs.racket-lang.org/guide/Lists__Iteration__and_Recursion.html#%28part._.Recursion_versus_.Iteration%29
<shawnw>
All iteration in scheme and racket is ultimately done via recursion. They're just two sides of the same coin.
bubblegum has joined #racket
<polarian>
shawnw: even vectors (arrays)?
<polarian>
however stack frame allocation to the heap is slower... would it not? constantly asking to allocate/reallocate memory, aka spamming the kernel with syscalls...?
<polarian>
however I assume if everything in scheme/racket is recursive orientated, then its a must...
<dzoe>
It is not "stack frame" in the sense a C stack frame is. And also "asking to allocate" - remember the runtime performing the "stack frame" (ehm, continuations) management, is the same runtime in charge of the memory. And no matter how you call that region of memory (stack, heap, my favourite part of RAM ...) it is always the same memory.
<dzoe>
Discussion can be made about cache affinity of such memory and other performance-related issues, but from algorithmic complexity perspective, you don't care. This just affects the constant factor.
<dzoe>
And also with CS all of this is DAMN FAST compared to typical naive C implementation.
bubblegum has quit [Read error: Connection reset by peer]
bubblegum has joined #racket
bubblegum has quit [Read error: Connection reset by peer]
bubblegum has joined #racket
bubblegum has quit [Ping timeout: 264 seconds]
bubblegum has joined #racket
bubblegum has quit [Read error: Connection reset by peer]
bubblegum has joined #racket
bubblegum has quit [Ping timeout: 264 seconds]
bubblegum has joined #racket
szkl has joined #racket
bubblegum has quit [Read error: Connection reset by peer]
bubblegum has joined #racket
bubblegum has quit [Read error: Connection reset by peer]
bubblegum has joined #racket
bubblegum has quit [Read error: Connection reset by peer]
bubblegum has joined #racket
chiselfuse has quit [Remote host closed the connection]