libera/#commonlisp - IRC Chatlog
Search
8:45:51
stylewarning
fiddlerwoaroof: thanks! Maybe when communication needs hit a threshold a channel can be made.
8:46:23
fiddlerwoaroof
stylewarning: have you thought at all about the representation of phantom type variables?
8:51:19
fiddlerwoaroof
It's one of my favorite tricks available with a nominal type system to help propagate information with no runtime cost
8:52:58
fiddlerwoaroof
But, it's a bit weird that there's no way to introspect the missing variable (afaict)
9:00:10
fiddlerwoaroof
Reifying them somehow would also let the constraints pass through untyped code
11:09:23
jcowan
You can discuss Coalton here, or of course in #lisp: it is a Lisp, so on-topic there
16:17:50
lisp123
Is there a optimal way to create a hash table with a custom test function, without defining your own hash function to go alongside the test condition?
16:27:20
pjb
You can create a hash-table with a test function AND a hash function. Note that sxhash is provided, but 1- it's not generic, 2- it's not necessarily good for your objects, 3- it's not used by CL hash-tables (or at least, it's implementation dependent whether it's used or not).
16:28:02
pjb
If by "optimal" you mean with minimal programmer effort, then you can create a hash-table as a wrapper with a custom test and hash-function using cl:hash-table to avoid having to re-implement everything.
16:28:28
pjb
lisp123: then, perhaps you have all the keys in advance? There are algorithms to create perfect hash-functions given a known list of keys.
16:30:28
pjb
Or you can write a wrapper computing the key: (defun get-my-key (list) (list (first list) (third list))) (setf (gethash (get-my-key (my-object-list object)) table) object)
16:32:05
lisp123
I have a function which can match two lists and disregard any discrepancies where there is a *
16:32:39
pjb
lisp123: if you have a finite number of combinations, you can have multiple entries in the hash-table.
16:34:07
pjb
And since possibly each pattern can match several object, you'd rather use push than setf.
16:34:19
pjb
(dolist (combination (compute-keys object)) (push object (gethash combination '()) table))
16:39:31
pjb
Then if you have lists, or similarly structured keys, you could have a tree of hash-tables.
16:41:23
pjb
(defun select (key table) (cond ((null table) nil) ((null key) table) ((eql '* (first key)) (mapcan (lambda (table) (select (rest key) table)) (hash-table-elements table))) (t (select (rest key) (gethash (first key) table)))))
16:59:20
pjb
pve: it may lack a ensure-list somewhere but the idea is that when there's a *, there may be multiple hits. So we return a list of results.