freenode/#lisp - IRC Chatlog
Search
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.