[ prog / sol / mona ]

prog


What are you working on?

18 2018-12-28 11:35

http://ix.io/1wVh

Some minor points:
- Please align the return of new-radix in copy-path-recur! with the 'if' block. Right now it's aligned as if it were a fourth argument to vector-set!. My python sense is tingling.
- There is an extract-5 in radix-delete for some reason.
- Reusing the name list->radix for the helper in (radix . elements) seems a bit inelegant to me.

And a note about radix->list. You are first testing whether the radix will be exhausted on this round and only after that whether the radix has already been exhausted. This is backward and your second case will never trigger. It is impossible that the radix will keep going after the current round, yet be exhausted already. Since you are already relying on the first case gracefully handling exhaustion by copying, listifying and appending an empty piece, you can simply dump the second case entirely rather than switching it to first. However, my suggestion is to construct the modulo piece first, then write a simple loop from below the modulo downward to zero and append the partial result to the new piece. Since the radix is accessed with radix-ref-height the same amount of accessing work is done by iterating backward. However, this way you would be appending to a piece of constant length at each step, which is linear behavior overall, whereas in your current version each step appends to a piece of linearly increasing length, which is quadratic behavior overall. Additionally, there is nothing forcing you to stick with vector->list and append!. You can have a helper deal with each new piece by consing a series of vector-refs backwards onto the result list, eliminating the need for vector->list and ditching append! and its import entirely.

I'm not a particularly experienced programmer

From your ease of use of named lets and the continuation trick of naive-append-vector!, I doubt that.

199


VIP:

do not edit these