extract analogous to extend?

Started by TedWalther, February 08, 2012, 10:07:45 PM

Previous topic - Next topic

TedWalther

I was just trying to use "pop" to pop several items off the front of a list.  I'm making a MIDI debugger.  I've been very happy with the ease that newLISP has allowed for bit-banging this serial protocol.



My only gripe so far is that there is no equivalent to "pop" that lets me take multiple elements from a list.  How about "extract" that is like "slice", but destructive like "extend"?   Or some boolean flag to slice?



That, and bind wants the variables in the association list to all have names that begin with Uppercase.  That is annoying.  I note that the examples in the manual don't require this.  Am I doing something wrong?  Bind+unify is very cool, but the Title-case requirement is a boner-killer.  Otherwise, a syntax like (setq '(a b c d) (some-function)) would be nice.  Similarly with the let family.  Or is this something where I am supposed to use macro wizardry by diving into my copy of Paul Graham's "On Lisp" and translating to newLISP?



Ted
Cavemen in bearskins invaded the ivory towers of Artificial Intelligence.  Nine months later, they left with a baby named newLISP.  The women of the ivory towers wept and wailed.  \"Abomination!\" they cried.

Lutz

#1
Can you tell us more about the application problem you want to solve and give code examples?

Lutz

#2
... also it is not true that 'bind' wants variables in title-case. Title-case is only required for variables in 'unify'.


> (bind '((a 1) (b 2)))
2
> a
1
> b
2
>


regarding your '(setq '(a b c d) (some-function))' snipped, perhaps you mean this:



> (map set '(a b c) '(1 2 3))
(1 2 3)
> a
1
> b
2
> c
3
>

TedWalther

#3
Yes, you are right, it is unify that wants title-case.  I feel foolish now; thanks for the map-set example.  That is what I wanted.
Cavemen in bearskins invaded the ivory towers of Artificial Intelligence.  Nine months later, they left with a baby named newLISP.  The women of the ivory towers wept and wailed.  \"Abomination!\" they cried.

William James

#4
I never thought of
(map set '(a b c) '(1 2 3))


... probably because it's not allowed in other languages.



Gambit Scheme:


4> (map define '(ee ff gg) '(22 33 44))
*** ERROR IN (console)@8.6 -- Macro name can't be used as a variable: define

rickyboy

#5
Don't know about Scheme, but in SBCL:
* (mapc #'set '(ee ff gg) '(22 33 44))
(EE FF GG)
* ee
22
* ff
33
* gg
44
(λx. x x) (λx. x x)

William James

#6
Quote from: "rickyboy"Don't know about Scheme, but in SBCL:
* (mapc #'set '(ee ff gg) '(22 33 44))
(EE FF GG)
* ee
22
* ff
33
* gg
44


Yes, I later realized that.  My post has been corrected.