Search
Monday, 7th of June 2021, 20:10:22 UTC
3:05:45
beach
Good morning everyone!
5:03:54
rbtEngrDude
** NICK rbtGotKicked
7:23:40
Colleen
Clhs: section 5.2 http://www.lispworks.com/documentation/HyperSpec/Body/05_b.htm
7:51:57
hirez
so I wrote an implementation of graham's scan in CL and it actually works :D
7:51:58
hirez
https://hastebin.com/igapemasop.swift
7:52:21
hirez
its so elegant looking in cl, lol. If anyone has any feedback on how I can make this more...canonical lisp I'd appreciate it
7:53:56
beach
(setf i (+ i 1)) is better expressed as (incf i)
7:54:16
beach
There is no need for a newline after LET* when the body lines are not long.
7:54:28
hirez
old habits from less refined languages die very hard
7:54:59
beach
Similarly, no need for a newline after a PROGN.
7:55:43
hirez
I see yeah, paredit cleans up nicely when I remove it.
7:55:45
beach
Instead of using PUSH and REVERSE, you can use COLLECT in LOOP.
7:56:16
moon-child
hirez: I think it would be cleaner to avoid the pushes in the body, as in (let* ... (stack (list (pop sorted) min))
7:56:46
hirez
Could I? I basically have to hold an element in `sorted` based on the `left` function. I will read up on collect.
7:57:10
hirez
Im not sure how I could avoid the push because the algorithm is dependent on a stack. I'd be interested in hearing how to avoid it.
7:57:10
beach
hirez: You would need an IF clause in the LOOP.
7:57:42
hirez
I see, I'll crack open the hyperspec again.
7:58:04
hirez
ooh I see what you mean moon-child
7:58:11
hirez
yes indeed I can remove those
7:59:42
moon-child
(that's a matter of personal style, though; others would consider it more consistent to view the algorithm as a sequence of pushes onto an empty list)
8:08:35
dsk
hirez: It's best not to try to destructively modify a literal object. That has undefined consequences.
8:09:49
dsk
You can cons up a fresh empty list with (list) instead of using '().
8:10:11
beach
dsk: That's not correct.
8:10:14
moon-child
(list) doesn't cons anything, it returns NIL
Tuesday, 8th of June 2021, 8:10:22 UTC