freenode/#lisp - IRC Chatlog
Search
22:28:18
dxtr
If I have to construct a separate list for it first then that's fine - but is there a suitable function for that?
22:32:10
actuallybatman
dxtr: I would do: `for i from 0 to (-1 (length list))` instead of `for elt in list` and offset the pointer as needed. maybe do a macro that captures prev and next per iteration to hide the loop details.
22:32:12
no-defun-allowed
(defun mapold (function &rest lists) (apply #'mapcar (lambda (&rest args) (list args (apply function args))) lists))
22:32:51
pillton
dxtr: (reduce (lambda (last current) (print (list last current)) current) (list 2 3 4 5) :initial-value 1)
22:36:34
tempate
is this function well written or can it be improved? https://bpaste.net/show/4f85298c746e
22:37:52
tempate
on a different note, is it possible to change where a cons should point to in a list? That is, can I make the second element point to the fourth, removing therefore the third from the list?
22:39:11
verisimilitude
Yes, tempate; there are RPLACA and RPLACD functions for this, although you'll usually want to use (SETF CAR) and (SETF CDR).
22:42:31
pjb
tempate: otherwise, it does exactly the same as yours, how can you say it's hard to follow?
22:47:33
makomo
tempate: it's like FLET, except it allow recursion and one function referencing another
22:54:37
aeth
prog and go instead of labels? something something lambda the ultimate something something
22:55:01
pjb
tempate: so the micro-optimization here is to choose between two local variable and a list, knowing that sometimes you will just throw away the list (ie. when the run length is 1).
22:55:53
pjb
tempate: also, since having a list is so important here, I would avoid `(1 ,i) and use instead (list 1 i). (actually I would use (setf run-length 1 item i)
1:11:05
Xach
dxtr: i have a trick i use but i don't know if it fits your situation, just curious about it.
5:58:25
fiddlerwoaroof
dxtr: one trick I've thought of is to use a cons cell where the car is a stack of previous items and the cdr is the remaining list
6:09:40
fiddlerwoaroof
here's a non-mutating version: https://fwoar.co/pastebin/676375393d12b9ba8ad525c85363b732e5c9604c.lisp.html
7:04:15
asarch
Just in the case if you are wondering if PortableAllegroServe can do REST API, the answer is yes:
7:08:45
asarch
A 40 years old programming language can use a 20 years old program to develop nowadays web applications!
9:02:31
splittist
Once again I am amazed by how a short period of concentrated thought is a substitute for hours of key bashing. And how hard it is to carve out time for concentrated thought.