freenode/#lisp - IRC Chatlog
Search
9:45:25
boeg
if I have a hash table `hash-t` and two variables `key-a` and `key-b` bound to `(cons 1 0)` and I do `setf (gethash key-a hash-t) 1)` why can't I do `(gethash key-b hash-t)` to access the value stored at `key-a`? My guess is that the key where I stored the `1` is a reference to the `key-a` variable, and so even though `key-b` contains a similar looking cons, it's not the same, so it doesn't work, but how do I make it work?
9:49:19
boeg
right, maybe I should check again, because I blindly tried telling gethash to use equal with `:test #'equal` but it didn't work and I just ... yeah, take a look at the documentation again :)
10:30:14
boeg
It throws you around in corners you wouldn't have thought of yourself. I have been reading practical common lisp and land of lisp a bit, but there's nothing like real experience, even though advent of code is taking me soo much longer compared to if I was doing it in a language I know better
10:56:35
heisig
Speaking of advent of code - anyone interested in sharing solutions? Here are mine: https://github.com/marcoheisig/adventofcode
11:01:03
no-defun-allowed
Should I start doing those kind of problem sets? Usually I find approaching whatever comes to mind more enjoyable, but I've heard several times that usually those tend to not be unfamiliar or difficult.
12:19:22
boeg
So whats a good source for how to set up a common lisp project? Right now I just create .lisp files and manually use quickload to load dependencies - well, dependency, I have only used a single library yet, split-sequence :P - but I was thinking if theres a good source to create a project for my advent of code project where I can have it handle bringing in split-sequence and so on
12:23:14
_death
http://stevelosh.com/blog/2018/08/a-road-to-common-lisp/ see section titled "Systems"
12:23:37
earl-ducaine
boeg: You'll find all the sources of the projects that used at: quicklisp/dists/quicklisp/software/
12:24:18
earl-ducaine
boeg: each one will have at least one *.asdf so you'll have a bunch of examples of how to write them.
12:26:46
earl-ducaine
boeg: ASDF has a comprehensive manual, so you should get that. But a warning, it's quite terse.
12:27:20
boeg
earl-ducaine: I'm checking out the stevelosh article right now, and then I'll see afterwards if i'm still missing things :)
12:27:24
earl-ducaine
boeg: It has few examples and for stupid people like myself it can be frusterating to use on its own.
12:29:35
earl-ducaine
boeg: one thing that you'll find quite convenient once you have your ASDF project set up is creating a symbolic filesystem link to it at: quicklisp/local-projects/
12:30:05
earl-ducaine
boeg: Then you'll be able to load it using quicklisp! e.g. (ql:quickload :my-new-project)
14:38:05
didi
Each tabulated data file use a different convention to separate records, fields, to escape characters...
14:44:39
dlowe
web folks love JSON, business folks still love XML AFAIK, but yeah, no one respected XML enough to use the encoders.
14:53:12
White_Flame
because they're compelled and don't actually love it, they don't care about implementing it properly
14:55:28
dlowe
I disagree with your causation. I think caring about proper implementation is only weakly correlated.
14:59:38
dlowe
the other source is that C++ libraries for emitting XML were (and perhaps still are) crazy terrible
15:12:25
didi
Those who say "don't use regular expressions to parse html" are only partially correct. HTML in the wild is a total mess.
15:14:00
phoe
if lispers closed parens as consistently as html writers closed tags then Lisp would fail to compile in 99 cases out of 98
15:17:26
dlowe
didi: I think the advice is actually to use a library (i.e. someone else's regular expressions) to parse html
16:10:02
Shinmera
The call for papers for ELS20 is now online! https://european-lisp-symposium.org/2020/index.html
16:12:08
vms14
Guys I want to rotate a list, but rotatef does not really "rotate" it just switches positions. I'm using (cons (car (last the-list))) + (remove (car (last the-list)))
16:13:40
vms14
I'm trying to make the snake game and the snake is just a list of points, to move the snake, I want to rotate the last item so the last part of the tail will be the head
16:15:43
Bike
well you compute LAST twice, and you use REMOVE even though you only want one element removed
16:27:40
vms14
thanks dlowe, I guess I'll use that and just update the list every time I push a new item
16:29:33
vms14
should I save the list before making it circular? so to push stuff I can update the saved list
16:34:36
beach
Here is another piece of advice for you: "advice" does not take a plural form. It is like a substance in English. In singular, it would be "a piece of advice". :)
16:35:44
vms14
people just let me kick the English dictionary and they say nothing, but this way I'll never learn
16:38:18
beach
clothespin: Nothing substantial. I have been giving some thought to how to compute indentation, which is why I suspended development on it. But I am mostly working on SICL now.
17:13:09
pjb
minion: memo for vms14: you can rotate a list in a user friendly way with two rotatef: https://pastebin.com/32mSuwkr
19:00:23
minion
vms14, memo from pjb: you can rotate a list in a user friendly way with two rotatef: https://pastebin.com/32mSuwkr
19:03:02
reepca
is there an equivalent to make-string-output-stream but for writing bytes instead of characters?
19:06:03
vms14
To read the raw bytes, you need to pass OPEN an :element-type argument of '(unsigned-byte 8).
19:14:54
pjb
reepca: there is, but do you realize that you can just as well and even more efficiently just write into a vector?
19:15:34
pjb
(let ((output (make-array 1024 :element-type '(unsigned-byte 8)))) (setf (aref output 0) 42) (replace output #(1 2 3) :start1 1) etc… output)
19:21:34
vms14
I'm not sure, but I think with a circular list I'll need to save the list before being circular, or remove the last element any time I'll update it
19:28:31
vms14
instead of moving all the "points" you just make the last point of the tail be the head
19:29:16
pjb
Since there is a maximum snake length, you could use a vector, and too indices (head tail).
19:32:11
pjb
A cell can contain a code to represent empty apple and the various possible snake sections. (up down) (up left) (up right) … (down left) (head up) (head down) … (tail right) (tail left).
19:33:23
pjb
So to find the snake you only need the head and tail coordinates, and you can know what cell to update by using the code for the from/to cells.
19:35:52
pjb
Obviously when we have gigabytes of RAM, nothing matters much anymore. It would be different in 1KB :-)
19:37:07
vms14
I like what you say about having everything in the board directly, so every cell has a value. I had this in mind for another game
19:37:52
vms14
but for the snake I think is even easier to have a list of points being the snake, and check those points
19:38:47
vms14
for moving I only need to rotate the last element so it will be the first (head) and 1+ point-x for example if it moves to the right
19:39:28
pjb
vms14: this solution would work well for very big boards. With 5K screens, you could easily go up to (640 360) cells.
19:40:27
pjb
So instead of pre-allocating 230K cells, you would just have a list of apples, and grow a list for the snake; the user will probably fail long before reaching a 230K cell long snake.
19:41:51
vms14
because I wanted to do that in other game, so it would be a nice opportunity to get used to this approach
19:43:17
pjb
didi: haven't you not considered com.informatimago.common-lisp.cesarum.ascii:read-ascii-line ?
19:47:38
jasom
Is there a standard anaphoric prog1? It occurs to me it might be useful for something like (prog1-a (make-array ...) ...)
20:37:56
fiddlerwoaroof
jasom: I've found prog1-bind more useful: https://github.com/fiddlerwoaroof/fwoar.lisputils/blob/012d021dc42bdfc4de9d26306c13fe0e48e9db93/fwoar-lisputils.lisp#L275-L278
20:38:22
fiddlerwoaroof
I've found that the problem with anaphoric macros is that you have to remember to import IT
20:39:56
pjb
Or that you cannot embed them easily. Better use: (defmacro with (it init-form &body body) `(let ((,it ,init-form)) ,@body ,it))
20:41:26
pjb
So it's better to let the user give the name of the it, in case there is this, that, and thot…
20:52:24
kmeow
i.e something like (defthing IAC 255) => (defparameter IAC (make-thing :name "IAC" :value 255))
20:57:07
kmeow
hm, weird ... I thought (string) wasn't working for me, but I may have misunderstood the error message
21:00:32
kmeow
okay, so I think my problem is I can't get the macro argument to expand inside "" marks