freenode/#lisp - IRC Chatlog
Search
16:57:53
jasom
when your string functions are compiled hand-optimized C and your byte functions are only slightly optimized byte code interpreted, there's no escaping the performance gap.
16:59:34
jasom
I also had 2 different people suggest using offset vectors instead of copying subvectors out both citing "performance" and both obviously never having actually benchmarked the difference...
17:00:19
jasom
I don't know if it's gotten better, but at the time simple-array was several times faster than non simple-array on sbcl.
17:52:27
jasom
and there's always dynamic programming version of fib: (defun fib (n) (if (< n (length *fibs*)) (aref *fibs* n) (progn (vector-push-extend (+ (fib (- n 1) ) (fib (- n 2))) *fibs*) (fib n))))
18:30:40
pjb
AFAIK, it didn't require hardware support. Wouldn't that be an interesting optimization to implement with a multi-generational copying garbage collector? (ie. older generations are not mutated, so we could cdr code lists in them without much drawback).
18:31:37
shrdlu68
When an array has an :element-type that is also an array, is it possible to have an :initial-element that won't just be the one same array?
18:34:19
pjb
shrdlu68: (map-into (make-array 3 :element-type '(vector t 4)) (lambda () (make-array 4))) #| --> #(#(0 0 0 0) #(0 0 0 0) #(0 0 0 0)) |#
18:35:08
pjb
shrdlu68: or (make-array 3 :initial-contents #(#(1 2 3 4) #(0 0 1 1) #(2 2 1 1))) #| --> #(#(1 2 3 4) #(0 0 1 1) #(2 2 1 1)) |#
19:03:00
jackdaniel
trafaret1: you may write a compiler in common lisp which will assemble sexp instructuions tailored for PLC
19:18:59
shrdlu68
Can someome make sense of this type-error? https://gist.github.com/shrdlu68/10ce10d70d4818017a174226382ba990
19:22:38
Bike
shrdlu68: (simple-array single-float 2) means a two dimensional array of single-floats.
19:23:03
pjb
shrdlu68: (typep (make-array 2 :element-type 'single-float :initial-element 0.0) '(simple-array single-float (2))) #| --> t |# that should work.
19:24:46
pjb
You're losing a lot of time with those type considerations. Wouldn't this time be better spent not putting any type declarations and improving your algorithms or your life?
19:25:45
pjb
Not counting that restricting the types of sequences or arrays will generally bite you in the ass later, when you want to pass some other type of sequence or array. Then you will have to copy, and become as slow as C++.
19:27:43
shrdlu68
pjb: sb-sprof says that (SB-VM::OPTIMIZED-DATA-VECTOR-REF T) is the function with the most sample, I'm trying to see whether I can optimize it away.
19:28:23
pjb
shrdlu68: but of course! It's always in optimized functions that all the time is spent!
19:55:01
pfdietz
There is an even better way of computing the n-th Fibonacci number, though, involving raising a certain 2x2 matrix to the n-th power. This takes O(log n) arithmetic operations (and with most of those having small size compared to the last O(1) iterations of the repeated squaring.)
20:59:50
aeth
Oh no. That's making me want to revise my project Euler code again. I think there's an n-th fib question or two
21:06:00
Bike
i remember the fib questions in euler generally being more about identities than computation
21:06:55
Bike
like sums of all, or odd, or even indexed fibonacci numbers are just otherfibonacci numbers, and stuff
21:08:50
aeth
I guess this new information won't be useful in my Euler lib (I separate my answers from the general algorithms/etc. used to solve the problem)
21:49:25
cl-arthur
There was a prime sieve implementation through infinite streams as one of the exercises in SICP if I recall correctly, fun stuff :)
21:52:49
russellw
I'm seeing recommendations to use (in-package :foo) to define your own namespace in which to define your functions and variables separate from anyone else's. I can see how that mostly works fine, but the problem is, suppose I'm writing e.g. a symbolic differentiation library. That needs to input (expt x 2) and return (* x 2), but expt and * need to be the standard ones, not the ones in package
21:58:16
aeth
russellw: You could do two things (and probably several other approaches) if you have to define your own *. You could call cl:* or you could define foo:* from a package that uses :cl
21:59:29
jasom
asarch: FWIW "Dynamic Programming" is a fancy name for something that basically boils down to speeding up recursive operations with memoization. As far as I can tell it got named that "because it sounded cool"
22:00:23
aeth
russellw: I haven't tested to see if this is portable yet, but for my Scheme I create a package called r7rs, but I don't in-package it, and just define r7rs::+, r7rs::*, etc.
22:05:15
jasom
russellw: the only reason *not* to :use "CL" would be if you want to have a distinct symbol with the same name as a standard one.
22:06:29
pjb
jasom: yes, there was a period where you had things like operational research, dynamic programming, artifical intelligence. Nowadays, we have deep learning, and stuff…
22:06:58
russellw
aeth, jasom, see, the thing is, I do not want to define my own *, and the problem is not getting to use CL, the syntax for this is straightforward. The problem is /quoted/ symbols. If I say '* then that will end up returning 'foo:*. I could firmly resolve in my mind to always write 'cl:* but in practice I would sometimes forget, and there is no way to automatically check for this error
22:07:57
aeth
russellw: I misunderstood your question, I thought you wanted separate symbols so (differentiate:expt x 2) would return '(cl:* x 2)
22:08:31
russellw
Right, no, I would actually rather avoid shadowing standard symbols where possible
22:09:40
aeth
For this sort of thing I tend to define both a macro and a function, where the macro is something like (defmacro foobar (form) (foo form)) or (defmacro foobar (&rest forms) (foo forms))
22:11:16
aeth
foo would be a function that takes '(expt x 2) and return '(* 2 x) while foobar would be a macro that calls that function, so it would evaluate (* 2 x) assuming x is defined, e.g. (let ((x 42)) (differentiation-macro (expt x 2))) => 84
22:12:07
aeth
(For the (&rest forms) version, you may want a slight variant like `(progn ,@(foo forms)) or `(progn ,@(mapcar #'foo forms)) etc. depending on your API of foo)
22:17:30
aeth
(In this very strange case you might want to insert a + in front and then feed `(+ ,@forms) into foo)
1:54:46
PuercoPop
Xach: Hi, what would be required for Quicklisp to update the ASDF version it updates to? Is there any reason besides not being a priority that Quicklisp doesn't update ASDF past 2.26?