libera/#commonlisp - IRC Chatlog
Search
4:03:28
beach
mzan: There is no reason to have a newline after LET*. And in Common Lisp, we don't have closing parentheses preceded by whitespace (and that includes newlines). Plus, there is no particular reason to have blank lines in the middle of top-level forms.
4:04:49
beach
mzan: And (lambda (ss) (series:collect-sum ss)) can be more simply expressed as #'series:collect-sum.
4:11:35
beach
jackdaniel: I am not sure from your demo what the improvement is compared to what things were before. Any hints?
4:16:43
Guest74
but asking about the function that returns the complement of a fucntion? probably complement?
4:17:06
beach
I haven't had my coffee yet, but perhaps (count nil ... :test-not #'identity) or (count nil ... :test #'not)
4:28:15
Guest74
I guess it probably wouldn't be good style to use it since :key sort of implies an accessor?
4:30:38
hayley
The :key and :test arguments are pretty open to interpretation to me. I recall mentioning some form in #commonlisp a while ago, something like (find 'integer '(fixnum real string) :test #'subtypep).
4:32:08
hayley
Worse, the :test doesn't have to be an equivalence relation. For example, (complement #'=) or #'/= is not an equivalence relation, but using either for :test is preferred over using the deprecated :test-not.
4:32:57
Guest74
well, I will happily abuse this if the opportunity presents itself. I notice clhs doesn't mention anything besides it being a designator for a function.
4:42:40
semz
I definitely find it more natural to enforce a predicate than to describe what I want removed.
4:43:15
semz
Do remove-if and remove-if-not predate the "filter" terminology that's more common nowadays?
4:44:19
hayley
The Standard ML function List.partition partitions into two lists instead, which seems nicer.
4:51:16
beach
I agree with hayley that FILTER is ambiguous. Plus, in Common Lisp there is the distinction between REMOVE and DELETE which is made explicit this way.
5:10:14
hayley
...notably, the competitions where people churn out code as quickly as possible. Not all competitions are based on programming speed.
5:16:25
hayley
Make sure you have loaded the split-sequence system, and then (split-sequence:split-sequence #\space "this is a string")
5:17:07
hayley
I'd usually say something right about now, but I don't have functions that replace and split strings.
5:17:49
hayley
But, yes, CL-PPCRE performs operations on regular expressions, and not just strings, so e.g. splitting on "|" might go sideways quickly.
5:18:16
hayley
I recall my first university assignment involved parsing "database" files which were | delimited, just to throw people off using .split() in Java, which takes a regular expression.
5:19:59
hayley
Amusingly, I was just about to ask something about regexen implementation: somehow an article I wrote on my regular expression compiler got big on Reddit and Hacker News. Someone asked me how I would handle character classes like \w or [:alpha:]. I suspect generating a whole lot of <= for each range is a terrible way to match a character class comprised of many ranges.
5:21:25
hayley
Another approach would be to use a bitmap, but we'd need a lot of bits for every Unicode character. And the generated code is quite fast, so having a large table also would result in more cache misses and more of a slowdown, which would be unfortunate. Is there a clever way to "compress" a bitmap in a way that allows for random access to the bitmap?
5:22:26
hayley
dre: I assume the documentation assumes you have used the package, but that is not a good idea, so you need to include the name of the CL-PPCRE package. Try (cl-ppcre:parse-string "(ab)*")
5:24:02
hayley
Prefixing everything with the package is usually easier on the person reading your code, so I would just do that.
5:24:57
hayley
Not by much. And it's better if your editor can complete names, so (cl-p <tab> p-str <tab> "(ab)*") might suffice.
5:27:52
hayley
Here is a hackish implementation of a "page table" which avoids requiring parts of the bitmap that are entirely 0 or 1 to exist in memory <https://plaster.tymoon.eu/view/2740#2740>, but I would guess testing for the sentinel values could confuse branch prediction.
5:28:19
hayley
Hm, I could hash cons instead, and there would only be one fully 0 page, and one fully 1 page.
5:31:31
dre
if I then redefine the function ( correcting the mistake), and then "Ctrl-D" to get out of the debugger...
5:32:54
dre
but I'm evaluating the defun in the debugger, then leaving the debugger, so I have the old version right?
5:33:33
beach
SBCL has only one global environment, so if you evaluate the DEFUN form in that environment, the old function will be replaced.
5:35:05
hayley
There is SLIMV for vim, though I have heard mixed things about it. Granted, I have also heard mixed things about SLIME too.
5:36:39
dre
I use "vim-slime" which, very basically, will send the paragraph I'm on to *another-terminal* with a <c-c><c-c>
5:37:33
Nilby
or you could be like me and not use SLIME/SLIMV/SLY anything, and even more naughty, use :use/use-package
5:57:28
hayley
It might be better to use DESTRUCTURING-BIND too. e.g. (destructuring-bind (action distance-string) (cl-ppcre:split " " item) ...)
6:07:00
abrahms
Hey commonlisp folks. I'm trying to figure out how to call a function if I have the string representing it's name. (funcall (intern "func-name-here") 1) doesn't seem to work.
6:08:14
hayley
The reader upcases symbol names by default, so you probably need to upcase the name yourself.
6:09:35
Alfr
abrahms, no but it won't intern a new symbol into package if func-name-here is misspelled.
6:10:00
jackdaniel
beach: on master the same code (sans cells are aligned differently, but that doesn't matter here) -- https://turtleware.eu/static/paste/incrm-table-old.mp4
6:16:00
_death
often when I want to have such dispatch equal is more appropriate.. but I do use equalp sometimes, either for such case-insensitiveness or for non-string array equality
6:24:45
jackdaniel
beach: well, the spec is quiet about what does it mean to propagate changes, so not strictly a bug
6:26:27
beach
So was the behavior different before when incremental redisplay was in use, compared to when it was not?
6:28:38
jackdaniel
I've been fixing issues for situation when some record was redisplayed that was not top level
6:31:46
beach
Every day, there are fewer reasons to choose an FFI-based solution to Common Lisp GUI applications. :)
6:57:55
hayley
You didn't provide a variable name to set in the SETF forms that comprise the body of the last WHEN form.
7:24:20
abrahms
Is there a utility function that amounts to "Given <list>, replace the 4th element with <thing> and return it to me"? I've looked and I can't quite find one. rplacd is as close as I've come and it's a bit wonky of an API
7:27:12
abrahms
Close. It returns `50`. I tried playing around with setf in the repl, but it was very angry about replacing constant data.
9:51:42
mzan
beach: apart these "cosmetic" details, sadly: 1) the library series was not able to execute correctly the same code, but written in a slightly different way; 2) my code is not 100% stream-oriented, because it can not process a file of 30Mb. It is ok for 16Kb
10:13:06
beach
mzan: I did not study your code enough to understand what it does, nor the problem to understand what the code is supposed to do.
12:13:06
jcowan
hayley: a classic hacque for Unicode char classes is to keep a sorted sequence of ranges as a vector. Contains is binary search, where the index mod 2 tells you if the char is in or out. Union and intersection are O(number of ranges), and complement is O(1)
12:14:19
hayley
Interesting. I'm not sure if O(log n) for contains would be okay, but I've set myself unreasonably high standards for scanning performance so far, honestly.
12:16:16
hayley
I already have such a sorted sequence to represent sets, but I don't want to give the branch predictor a hard time. I guess I can do a binary search of fixed length branch-free though.
12:18:55
hayley
...or perhaps my two level table idea, which would allow reusing the same #*0101... subvector for each group of characters.
12:20:08
hayley
From memory, ALPHANUMERICP had some 550 ranges or so, thus 10 iterations of binary search. Not sure if that is too many.
12:34:23
pdietz
The distribution of inputs is likely highly nonuniform in practice, which would speed things up.
13:20:23
pjb
hayley: perhaps not, when dealing with random unicode characters. it can be optimized for the iso-8859-1 case. But instead of using a binary search, perhaps one could have an indexed search. Are those ranges very non-uniformly distributed?