freenode/#lisp - IRC Chatlog
Search
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
23:04:15
Bike
seeing systems t hat define sequence methods beyond the core and iteration protocol would be interesting. if anyone happens to know any. if they even exist
23:09:27
jasom
Does CFFI have a type for a function pointer, or does it just assume that function pointers and data pointers are compatible?
23:35:00
_death
seems I got it working.. (bar (list 'a '(1 2 3 4))) => (A (4 3 2 1)) (with bar returning a foo with reversed array contents)
23:40:28
_death
I see some cffi tests failing, but it seems some unmodified cffi tests are failing as well
0:50:10
no-defun-allowed
Means the CR in CRLF isn't being handled as part of the newline separator somewhere.
0:53:25
pilne
I recently had to go back to windows for various reasons, and portacle has been a blessing so far
2:06:12
sjl
In hindsight, this (for ... matching ...) iterate driver may have been overkill, but at least it'll help make advent of code input parsing less tedious https://hg.sr.ht/~sjl/cl-losh/browse/default/src/iterate.lisp#L890
2:11:58
_death
sjl: last year I started writing utilities for AoC as well.. since I don't like to use regular expressions in code, back in 2018 I came up with this: https://gist.github.com/death/4ed89bf10404f5c71f1fb8f2a95a0f13
2:12:46
_death
incidentally, "slhelper" stands for "(Santa|Satan)'s Little Helpers" .. regexes in names are fine :)
2:18:43
_death
btw I found another bug, this time in cffi-libffi.. (defcfun foo :string) will try to foreign-string-to-lisp the pointer to the string pointer instead of the string pointer itself... other types may also have this issue, but I fixed it for foreign-string-type at least
2:21:46
_death
LdBeth: yes, a C string is a pointer to char.. cffi type :string automatically converts between foreign and lisp strings
2:32:29
pjb
LdBeth: I use (merge-pathnames (make-pathname :directory '(:relative) :name "ccl-init" :type "lisp") (user-homedir-pathname)) so it works everywhere!
2:34:35
pjb
LdBeth: a string is a vector of character. It's way more sophisticated than what C proposes.
2:35:19
no-defun-allowed
'<char>' is just syntactic sugar for the integer with the same value as the character's codepoint.
4:57:38
White_Flame
is there some sort of asdf extension out there that lets you place dependencies inside the individual .lisp files instead of in the .asd?
5:58:16
anlsh
When I do (ql:quickload :alexandria) I get the following error: The name "ALEXANDRIA.1.0.0" does not designate any package.
6:41:07
no-defun-allowed
ACTION waits for fully inferred systems, where hypothetically any time an undefined variable or function is used, its definition is searched for and the file containing its definition is loaded