extract analogous to extend?

Pondering the philosophy behind the language

extract analogous to extend?

Postby TedWalther » Thu Feb 09, 2012 6:07 am

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.
TedWalther
 
Posts: 603
Joined: Mon Feb 05, 2007 1:04 am
Location: Abbotsford, BC

Re: extract analogous to extend?

Postby Lutz » Thu Feb 09, 2012 5:45 pm

Can you tell us more about the application problem you want to solve and give code examples?
Lutz
 
Posts: 5276
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California

Re: extract analogous to extend?

Postby Lutz » Fri Feb 10, 2012 3:17 pm

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

Code: Select all
> (bind '((a 1) (b 2)))
2
> a
1
> b
2
>


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

Code: Select all
> (map set '(a b c) '(1 2 3))
(1 2 3)
> a
1
> b
2
> c
3
>
Lutz
 
Posts: 5276
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California

Re: extract analogous to extend?

Postby TedWalther » Sat Feb 11, 2012 5:59 pm

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.
TedWalther
 
Posts: 603
Joined: Mon Feb 05, 2007 1:04 am
Location: Abbotsford, BC

Re: extract analogous to extend?

Postby William James » Wed Mar 07, 2012 10:12 am

I never thought of
Code: Select all
(map set '(a b c) '(1 2 3))


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

Gambit Scheme:

Code: Select all
4> (map define '(ee ff gg) '(22 33 44))
*** ERROR IN (console)@8.6 -- Macro name can't be used as a variable: define
Last edited by William James on Wed Mar 07, 2012 9:12 pm, edited 1 time in total.
William James
 
Posts: 58
Joined: Sat Jun 10, 2006 5:34 am

Re: extract analogous to extend?

Postby rickyboy » Wed Mar 07, 2012 8:38 pm

Don't know about Scheme, but in SBCL:
Code: Select all
* (mapc #'set '(ee ff gg) '(22 33 44))
(EE FF GG)
* ee
22
* ff
33
* gg
44
(λx. x x) (λx. x x)
rickyboy
 
Posts: 572
Joined: Fri Apr 08, 2005 7:13 pm
Location: Front Royal, Virginia

Re: extract analogous to extend?

Postby William James » Wed Mar 07, 2012 9:13 pm

rickyboy wrote:Don't know about Scheme, but in SBCL:
Code: Select all
* (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.
William James
 
Posts: 58
Joined: Sat Jun 10, 2006 5:34 am


Return to Whither newLISP?

Who is online

Users browsing this forum: No registered users and 1 guest

cron