freenode/#lisp - IRC Chatlog
Search
13:16:43
dim
I have the good luck to learn lisp at school, in between C++ and Java. Unfortunately the teacher was so ignorant about it that we only played with cons, car and cdr and we had to answer cryptic exercises of no value. I guess the whole class was disgusted and saw no point in Lisp at all.
13:17:12
p_l
dim: that's common case in the vestigal courses that introduce various forms of programming
13:17:55
p_l
dim: in my case, I believe we had a bit of Prolog instead, don't recall if we had lisp directly, but we had a lisp-derived language (Jess) much later on
13:19:31
dim
Java has ABCL and Kawa too, and Clojure nowadays, if you depend on the JVM to run programs... but anyway
13:40:36
p_l
dim: Clojure is the only one that is widely known unless someone takes special effort to find
13:54:50
Baggers
ACTION googles lisp. lisp the lang beats lisp the condition, then its common-lisp.net then it's gigamonkeys
13:55:53
dim
you know that your google results depend on your habits and who you are seen from Google, right? e.g. if I search for “postmodern” the first result I have is the PostgreSQL driver for Common Lisp…
13:56:29
Baggers
did it from safari without being logged into anything. guess they are basing on ip then
13:58:22
edgar-rft
Search engines are not "intelligent" by default. If nearly nobody searches for Lisp stuff, Google can't know. Just as simple as that.
13:58:49
Baggers
fwiw got the same on chrome that I just ran for the first time on a phone i've just flashed in icognito mode and on 4g
13:59:14
dim
https://arstechnica.com/information-technology/2017/02/now-sites-can-fingerprint-you-online-even-when-you-use-multiple-browsers/
14:05:30
Baggers
ACTION would love to know what someone using some anonymizer/vpn/etc gets for googling lisp.
15:53:48
phoe_
where the library seemingly expects B G R A as it reads these values not as four (unsigned-byte 8)s but rather as one (unsigned-byte 32) which of course is little-endian
15:59:35
phoe_
edgar-rft: I'm passing a whole vector to Qtools's QImage to be displayed, so this doesn't help me.
16:06:26
pjb
phoe_: (loop for i :below (length v) :by 4 :do (rotatef (aref v i) (aref v (+ i 3))) (rotatef (aref v (+ i 1)) (aref v (+ i 2))))
16:13:06
pjb
phoe_: but the point is that when you have vector with O(1) access, you can loop with any O(1) number of variables by indexing the vector!
16:23:56
pjb
phoe_: now, of course, the right answer would be to update your functional asbtractions: (defun red (pixmap index) (aref pixmap (+ 2 index))) instead of (defun red (pixmap index) (aref pixmap (+ 1 index))) etc.
16:24:29
pjb
newcoder: writing the first version of a program that the programmer things will never be used by users, but that the manager has already sold and will distribute world wide.
16:27:10
pjb
The wrong way is to implement a user interface, to have a feel of how it will look, but not the internals. This is wrong, because then you will spend 2 years hearing why doesn't it work, since the UI is already done!
16:27:44
pjb
The okay way is to implement the core functionality/algorithm, and to stick a CLI on it, to validate the "MVP".
16:29:45
pjb
The advantage of CLI nowadays, is that no user expect to have to use it. So you can demonstrate the feature: look, I enter this data, I get this result, without the user expecting to have a finished product.
16:32:27
Josh_2
I'm not a very skilled Lisper but I can write programs much faster in Lisp than I can in C++
16:44:46
mr_yogurt
Are there any big utility libraries (maybe something like boost, although not exactly boost since a lot of it is unnecessary for CL) for common lisp?
17:25:02
pjb
(let ((a (aref pixmap (+ 0 index))) (r (aref pixmap (+ 1 index))) (g (aref pixmap (+ 2 index))) (b (aref pixmap (+ 3 index)))) …)
17:25:56
kenanb
I am feeding an ADJUSTABLE-ARRAY of type STRING with WORDs, I was expecting if I ADJUST-ARRAY with (LENGTH WORD) and just VECTOR-PUSH, it would perform better than doing VECTOR-PUSH-EXTEND for every single character. but it performed much worse. any quick ideas or would you like to check the source instead?
17:27:15
kenanb
sbcl sources doesn't call adjust-array but an extend-vector routine, so I guess it is a vector specific optimization
17:29:50
pjb
The only thing is that if it's adjustable without a fill-pointer, then it will adjust the vector, copying O(n) each time!
17:35:37
kenanb
I intentionally start with 0 size so I see how much allocation effects the timings better.
17:36:27
Bike
oh, i see, for the adjust-array you only adjust it by enough for the word, so you adjust every single iteration.
17:36:58
Bike
for vector push extend you call it in the inner loop, so it would be catstrophic if it only adjusted by one letter as you expected, but that's not the case.
17:38:19
Bike
i used to think of it the same way, but since practically every time you call vector push extend would be in a loop, it wouldn't be a reasonable way for the function to work
17:38:20
kenanb
though I wonder if there is a generic extension strategy among implementations, maybe the one pjb suggested is already the way it works?
17:41:18
kenanb
I get the exact same benchmark results when I add a min-extension of 1000 to the vector-push-extend, anything below results in longer times
17:43:50
kenanb
I will now try a version that first tries to push and if failed manually doubles the size, just to see if the timings will be close to the current best, but thank you Bike, pjb. now I at least know how to think about it.
17:47:38
Bike
probably to get it going really faster you could do an algorithm change, like avoiding separately consing up the list of words from ppcre split
17:51:10
kenanb
hmm, manually adjusting with big chunks if vector-push fails really gives the exact same timings, sometimes even slightly better, but this is not the best of benchmarks anyway.
17:53:10
pjb
vector-push-extend without the third argument will probably increment the size of the array by 1. So it's O(n).
17:53:31
kenanb
Bike: yeah, I am thinking of doing it for the actual implementation, this is for a blog post so I am modifying the code in small chunks
17:56:08
pjb
Try: clall -r '(let* ((s 3) (a (make-array s :adjustable t :fill-pointer s :initial-element :a))) (vector-push-extend :b a) (array-dimension a 0))' # with different s had have fun!
17:56:55
kenanb
yeah, even if SBCL does the optimization automatically, manually extending by big chunks is going to perform better regardless of implementation, which is cool
17:57:17
pjb
for small arrays, not all implementation increment by O(length(v)). but for larger sizes (>20), they all about double the size.
17:58:36
kenanb
does vector-push-extend only extends when the size is not enough, even if we supplied the min-extension arg?
17:59:10
pjb
Hence the interest of using fill-pointers: so vector-push-extend doesn't extend in general.
17:59:50
kenanb
if so, vector-push-extend already will do exactly what I am trying to achieve by trying vector-push first, and then doubling the size?
18:25:13
Josh_2
How do I abs two values? Or in C++ a complex like so http://www.cplusplus.com/reference/complex/abs/ I just made my "complex" a list of two numbers, not sure if I'm doing it right
18:28:02
White_Flame
if you're injecting complex literals into your code, use #c. Otherwise, any math that returns complex numbers should return complex numbers on their own
18:28:34
White_Flame
if you have 2 numbers from which you want to construct a complex number, then it's (complex <real> <imag>)
18:41:28
Josh_2
although I wouldn't mind experimenting with a library that lets me plot pixels to the screen
18:52:25
francogrex
i defined my class (defclass my-class () ...) later on if i want to use it as (make-array length :element-type (vector my-class *)) << is this right (vector my-class *) ?
19:00:09
francogrex
it's a little bit disconcerting that the REPL prints the array with zeros as such #(0 0 0 0 0 0 0 0 0 0) no sense to what i defined it to be
19:01:08
kenanb
I was able to get much better timing with initially allocating 4 and multiplying the allocated size by 16 when required. I tried with various string lengths and it was always the best score.
19:06:18
Bike
francogrex: element type is the type of the ELEMENTS of the array. (make-array length :element-type 'integer) is a vector of integers
19:12:17
francogrex
yes that (make-array 5 :element-type 'integer) returns an array with #(0 0 0 0 0) but when you do (make-array 5 :element-type '(vector integer 3)) why #(0 0 0 0 0) is also returned?
19:13:55
Bike
Okay, so under the hood your lisp implementation probably only has special vectors for a few things.
19:14:36
Bike
it doesn't know about your particular class, or store vectors specially, or anything. So it "upgrades" that type specification to something it does know about, which is probably T.
19:14:53
Bike
If you do (array-element-type (make-array 5 :element-type '(vector integer 3))) you'll probably get T
19:17:28
Fare
Select D took me to the documentation and Show Candidates Backtrace told me that c-B would show the backtrace
19:18:44
francogrex
ok so (make-array 5 :element-type 'character) is fine, (make-array 5 :element-type 'bit) is fine (i mean shows what expected ... but that's just it the rest is T
19:20:27
Bicyclidine
When you try to make a vector of (vector integer 3), it makes a vector of T. It picks 0 as an initial element, which is fine, because 0 is a T.
19:21:27
Bicyclidine
Because your implementation has special character arrays, and picked a different element for them.
19:21:46
Bicyclidine
If you did (make-array 5 :element-type '(vector character)) you'd probably get #(0 0 0 0 0) again.
19:23:22
Bicyclidine
If you want the vector to be filled with strings you can specify a string it can be filled with.
19:23:54
Bicyclidine
Lisp does not actually know how to take a type and make a valid "zero" object of that type anyway.
19:25:35
francogrex
so where do those 0s come as default? Bicyclidine yes but in that case, the :element-type is irrelevant then
19:26:09
Bicyclidine
Not when you want your element type to be a vector type, no. I think that was established by my explanation of upgrading.
19:26:48
Bicyclidine
The implementation can't really do anything special if it knows that an array is only going to hold vectors, because vectors are complicated objects. So it just uses its basic complicated object type, T
19:27:23
Bicyclidine
The 0 is probably just the default initial element for arrays specialized to hold general objects.
20:00:08
stylewarning
PuercoPop: I found an issue with the recent FIASCO change to use synonym streams
20:26:45
PuercoPop
stylewarning: in retrospect it was a bad proposal on my part. If we use synonym streams we should just write the the *test-run-standard-output* instead
20:30:07
PuercoPop
I'm not sure I understand the purpose of defining a stream for testing and then binding *standard-output* to it and write to *standard-ouput* instead of writing the stream directly
20:51:28
PuercoPop
stylewarning: I'm under the impression that this bind to the eval *standard-output* was done by atilia to mimick what make-synonym stream accomplishes