freenode/#lisp - IRC Chatlog
Search
6:53:22
elderK
Guys, is there a way to have nested loops with LOOP such that the variable def/stepping is after the say, body, (when, etc.)?
7:05:51
beach
In other words, every clause is going to be executed at most once in each iteration of a LOOP.
7:18:51
no-defun-allowed
An oversimplification would be that you start with everything indented just to the right of the LOOP symbol, then every conditional body form is indented in two spaces.
7:37:35
elderK
Perhaps I should learn to read Emacs Lisp so that I can decipher the rules from the indentation contribution
9:31:03
francogrex
Hi all. I am using emacs inferior-lisp to run CL interatively in emacs. however I am creating a game and would like at a certain point to clear the emacs buffer where my lisp is running. I could execute the emacs command (erase-buffer) from emacs e.g. M-x erase-buffer... but can i do it from inside the CL program itself?
9:31:46
francogrex
you know like (run-program bla bla) or something similar? need to execute the elisp command from inside common lisp?
10:02:32
Nilby
francogrex: It's probably best not to do this. If you are making a game with terminal effects like clearing the screen, it's best to use a terminal library like cl-charms and run in the terminal. If it's just for you the developer, it's best to just do it on the emacs side with a elisp. BUT, if you run slime instead of inferior-lisp there is swank:eval-in-emacs, which could do something like that. Note that lisp programmers might be
16:58:22
beach
I think I have a version of my paper on representing method combinations that is close to finished. If anyone feels like reading it, this is your opportunity to appear in the "Acknowledgments" section. Deadline for submission is in a week or so. http://metamodular.com/SICL/representing-method-combinations.pdf
17:18:09
tempate
I want to make a function that takes in a list, picks an element at random, removes it from the list and returns it.
17:18:17
tempate
I've got under control the get-element-from-list part. What I am not sure about is how to remove it from the list.
17:18:59
tempate
To be clear, I want to alter the inputted list, not to return a list without the chosen element.
17:23:38
beach
tempate: You realize that what you want is not possible in general with a function, right?
17:24:17
beach
tempate: You can't write a function that deletes the first element of a list destructively, for instance.
17:24:33
pjb
tempate: (it's true that most implementation, in SOME cases, will mutate the cons chain, but it's far to be the case always.
17:25:04
pjb
(define-modify-macro deletef (item &rest keys) item-delete "Delete the item from the sequence in PLACE.")
17:26:54
pjb
(setf *print-circle* t) (let* ((list (list 1 2 3)) (original list)) (deletef list 1) (list original list)) -> ((1 . #1=(2 3)) #1#)
17:28:50
tempate
Would it be a more lispy solution to just remove the item from a copy of the list and return both the new list and the chosen element?
17:28:51
pjb
Of course, you could write your own delete function that would mutate it. For example, it could put a NIL in the CDR of the first CONS cell.
17:29:47
pjb
tempate: don't think lisp. Think what should my program do so you can sell it for a billion and finance whatever you want (Venus exploration, development of a Lisp OS, a Pacific Island, whatever).
17:32:27
pjb
tempate: well, for your goal function, you have to choices. Either you want to use lisp lists, which don't exist as an ADT, but are merely chains of cons cells, and then you will have to return indeed two values, the extracted element and the new list, or you introduce your own list ADT (eg. a class or a structure that wraps a lisp list), and then you can mutate the list and only return the extracted element.
17:32:59
pjb
tempate: in any case, since the list can be empty, you could have no element to return, so returning multiple values including an indicator that the list was empty should be envisaged.
17:35:14
Nilby
pjb: Yes. That's the elegant way. But wouldn't tell someone who's unfamiliar with delete to do it that way at first.
17:35:37
pjb
tempate: an alternative, is to pass a "place" to your function. If you write a macro, you must mind using get-setf-expansion. But you can pass a place to a function by way of a closure.
17:36:08
tempate
pjb: I think I'm going to write a class. It'll most likely come in handy in the future.