freenode/lisp - IRC Chatlog
Search
8:34:59
Grue`
aeth: yeah it's called MAPCAN: (mapcan #'(lambda (x) (and (numberp x) (list x))) '(a 1 b c 3 4 d 5)) => (1 3 4 5)
8:47:10
shaftoe
if my function's argument is a list containing one specific type... is there a way to help compiler beyond (declare (type list x))
8:48:34
Xof
if you know the length of the list you could (declare (type (cons integer (cons integer (cons integer (cons ... null)))) x)) but that's really a terrible idea
8:49:48
shaftoe
i have plenty of functions that take lists as arguments, but i've always wondered how to optimize them further
8:51:28
pjb
notice that there's no optimization to be have, by declaring the type of all the elements of a list, since cons cells are the same for any type of element.
11:19:05
libreman
The problem is that within swank the file location is passed to definition-source-for-emacs for non expanded (read) code and slime gets the location for the expanded code. And as cl-annot generates code this is new location is not correct
15:13:30
beach
Slow but steady progress. I am working on a library that will allow for source tracking in a compiler or editor.
15:13:51
beach
At the same time, I am working on the incremental Common Lisp parser for the Second Climacs editor.
15:22:42
python476
right now I'm off computing (electronics), a bit before that I was trying to write a tiny lisp in pascal :)
15:24:58
beach
I was working for a company that had a rule that everything had to be written in Pascal.
15:27:25
malice`
I also wanted to get clever with format and do something like (format t "~{~A~}~%" (make-list 25 :initial-element #\=)) but that's longer
15:51:57
p_l
malice`: ... somehow I got from there to (princ (make-array 15 :element-type 'standard-char :initial-element #\=))
16:04:31
malice`
I have a tree. I want to provide a generic function that would allow for using a function on each element of the tree (let's call it maptree). I also want for the user to be able to provide the traversal method from the default - e.g. in-order, post-order, ... - or instead pass a custom function that would walk the tree.
16:06:08
malice`
I think that's quite okay; however, my concern is that I define it as a generic function, but traversal methods might be different for different classes (some class might want to have a method with e.g. :fast traversal implemented that would be unique to it), but documenting the method isn't that useful in CL imho, then documentation isn't helpful on the matter of traversal method. Is my concern valid?
16:07:35
phoe
what you describe looks like a name collision for two classes that want the :fast keyword to mean different things
16:08:20
malice`
I define a general "trie" class, then "standard-trie" (or something like that) that derives from trie
16:08:27
phoe
malice`: that's what my question meant; good, then you can freely use generic functions.
16:08:57
malice`
that would behave a little bit different with its keys, and write new methods for them
16:10:13
malice`
I was thinking more of a scenario where e.g. standard-trie has (:default) as list of possible traversal methods
16:10:26
malice`
and someone implements nonstandard-trie which has (:default :fast) as traversal methods
16:11:13
phoe
(defmethod traverse ((tree randomly-sorted-tree) (traversal-method default-traversal)) ...)