freenode/#lisp - IRC Chatlog
Search
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
21:14:36
kmeow
I'm getting (format nil "~a" IAC), but I need (format nil "~a" 'IAC), which I haven't yet found a way to do
21:32:02
pjb
kmeow: (defmacro defthing (name value) (let ((sname (string name))) `(list ',name ,sname ,value))) #| --> defthing |# (defthing iac 255) #| --> (iac "IAC" 255) |#
21:32:35
pjb
kmeow: notice how my *print-case* is set to :downcase. So using format ~A would generate "iac" instead of "IAC". Using string or symbol-name is better if you want to have a consistent case.
21:34:20
pjb
kmeow: nirved solution computes the string at run-time. This might be not what you want.
22:14:59
_death
I wonder, does this cffi code make sense to anyone? https://github.com/cffi/cffi/blob/master/src/types.lisp#L562
22:17:38
_death
an aggregate-struct-slot has a count, but the methods defined for it take no notice (and foreign-struct-slot-value errors with missing method for translate-aggregate-to-foreign when I trying to use)
22:35:32
_death
but given (defcstruct foo (a :int :count 4)) and (defcfun bar :void (foo (:struct foo))), C function void bar(struct foo foo);, a call like (bar (list 'a '(1 2 3 4))) will result in the error I mentioned
22:43:26
Bike
Shinmera: do you actually use extensible sequences? i'm looking for examples of users but github search is as shit as always
22:47:39
Bike
i'm implementing it in clasp (no surprise there) and am wondering about how the actual sequence functions should work. like map and stuff
22:47:57
Bike
the way sbcl is written, if you map to an extended sequence type, it always calls sequence:map
22:49:25
Bike
it has to deal with an unknown number of sequences (i.e. a list of sequences), so it conses a list of iterators
22:49:32
fiddlerwoaroof
e.g. I have a class that represents a RSS or Atom feed and it uses the protocol so you can use remove-if* to filter the items
22:51:03
Bike
well most of the time you call map you're actually writing, you know, like (map ...), so the number of arguments is known at compile time
22:54:30
Shinmera
In any case it's too late and my brain is fried, so I don't think I have any useful input on this.
22:55:40
Bike
there are two different efficiency concerns - this map unrolling biznis, but also the sequence might have some specific ability to be more efficient. if the protocol is such that sequence:map HAS to be called, you only get the latter. if not, only the former