Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
How can I implement a function inside of a list?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  8 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Sungwoo Lim  
View profile  
 More options Jul 24 2001, 5:10 am
Newsgroups: comp.lang.lisp
From: Sungwoo Lim <sung...@cad.strath.ac.uk>
Date: Tue, 24 Jul 2001 10:09:58 +0100
Local: Tues, Jul 24 2001 5:09 am
Subject: How can I implement a function inside of a list?
Hello,

Suppose, I have a function TEST as below.

(defun test (i)
  (loop for j from 0 to (- i 1)
        do (print j)))

And, suppose I got a list as below.

3 > (list 'test 10)
(TEST 10)
3 >

How can I get the result of the TEST function from the above list
directly?

Thanks in advance,

Sungwoo


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Patrick W.  
View profile  
 More options Jul 24 2001, 5:39 am
Newsgroups: comp.lang.lisp
From: anapra...@yahoo.com.au (Patrick W.)
Date: 24 Jul 2001 19:59:32 +1000
Local: Tues, Jul 24 2001 5:59 am
Subject: Re: How can I implement a function inside of a list?

Sungwoo Lim <sung...@cad.strath.ac.uk> writes:
> Hello,

> Suppose, I have a function TEST as below.

> (defun test (i)
>   (loop for j from 0 to (- i 1)
>         do (print j)))

> And, suppose I got a list as below.

> 3 > (list 'test 10)
> (TEST 10)
> 3 >

(apply #'funcall (list 'test 10))

Is that what you meant?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kalle Olavi Niemitalo  
View profile  
 More options Jul 24 2001, 6:15 am
Newsgroups: comp.lang.lisp
From: Kalle Olavi Niemitalo <k...@iki.fi>
Date: 24 Jul 2001 13:14:14 +0300
Local: Tues, Jul 24 2001 6:14 am
Subject: Re: How can I implement a function inside of a list?

anapra...@yahoo.com.au (Patrick W.) writes:
> (apply #'funcall (list 'test 10))

Which one is clearer, that or (apply (car list) (cdr list))
(assuming LIST is such a list)?  Your version is a little
shorter, but it has kind of a double indirection.

Note to OP: If the list were '(test foo), then the argument to
function TEST would be the symbol FOO and not the value of the
variable FOO; but you can use (list 'test foo).


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sungwoo Lim  
View profile  
 More options Jul 24 2001, 6:23 am
Newsgroups: comp.lang.lisp
From: Sungwoo Lim <sung...@cad.strath.ac.uk>
Date: Tue, 24 Jul 2001 11:22:53 +0100
Local: Tues, Jul 24 2001 6:22 am
Subject: Re: How can I implement a function inside of a list?
In article <87k80ywsu3....@ivory.localhost>, Patrick W.

<anapra...@yahoo.com.au> wrote:
> (apply #'funcall (list 'test 10))

> Is that what you meant?

Yes, that's kind of what I mean, however, I put the wrong example.
Sorry. Actually, I am trying to implement following DEFDIAGRAM.

;-------------------------
; Line-drawing labeling
; in Paradiams of Artificial Interlligence programming, chapter 17.
;
(defdiagram cube2
   (a W e b c)
   (b L d a)
   (c Y a d f)
   (d W b g c)
   (e L a f)
   (f W g e c)
   (g L f d))

(defmacro defdiagram (name &rest vertex-descriptors)
  `(put-diagram ',name (construct-diagram
                         (check-diagram ',vertex-descriptors))))
;----------

I got a label list of a cube by some calculations as below,

((a Y b c d) (b W g e a) (c W e f a) (d W f g a) (e L c b) (f L d c) (g
L b d))

and wanted put into the (defdiagram shape ) like the above example.
But (apply #'funcall ) doesn't works for this case...

> Error: #<Compiled-function DEFDIAGRAM Macroexpander #xCDB2BD6> can't be FUNCALLed or APPLYed.
> While executing: "Unknown"

Also, it seems I cannot put the list element into defdiagram directly...
I tried some other experiments, and failed as
;-------------------------
(setf dlist (list '(a W e b c) '(b L d a) '(c Y a d f)
                  '(d W b g c) '(e L a f) '(f W g e c)
                  '(g L f d)))

(defdiagram cube
  (first dlist)
  (second dlist)
  (third dlist)
  (fourth dlist)
  (fifth dlist)
  (sixth dlist)
  (seventh dlist)) ; dumb...
;-------------------------

Any ideas to implement this macro with a provided list plz?
Thanks alot,

Sungwoo


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Erik Naggum  
View profile  
 More options Jul 24 2001, 8:01 am
Newsgroups: comp.lang.lisp
From: Erik Naggum <e...@naggum.net>
Date: Tue, 24 Jul 2001 12:01:50 GMT
Local: Tues, Jul 24 2001 8:01 am
Subject: Re: How can I implement a function inside of a list?
* Sungwoo Lim <sung...@cad.strath.ac.uk>

> I got a label list of a cube by some calculations as below,

> ((a Y b c d) (b W g e a) (c W e f a) (d W f g a) (e L c b) (f L d c) (g
> L b d))

> and wanted put into the (defdiagram shape) like the above example.
> But (apply #'funcall) doesn't works for this case...

  This is the closest to what the Lisp environment will do if you type it
  in like you seem to want to do:

(eval (list* 'defdiagram 'cube <list>))

  You will hear a lot of whining from people who think eval is evil.
  Ignore them for now.

  However, the macro is actually pretty well-behaved, so you can easily do

(put-diagrem 'cube (construct-diagram (check-diagram <list>)))

  which should produce the desired results.

#:Erik
--
  There is nothing in this message that under normal circumstances should
  cause Barry Margolin to announce his moral superiority over others, but
  one never knows how he needs to behave to maintain his belief in it.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sungwoo Lim  
View profile  
 More options Jul 24 2001, 8:49 am
Newsgroups: comp.lang.lisp
From: Sungwoo Lim <sung...@cad.strath.ac.uk>
Date: Tue, 24 Jul 2001 13:49:14 +0100
Local: Tues, Jul 24 2001 8:49 am
Subject: Re: How can I implement a function inside of a list?
In article <3204964907881...@naggum.net>, Erik Naggum <e...@naggum.net>
wrote:

>   This is the closest to what the Lisp environment will do if you type it
>   in like you seem to want to do:

> (eval (list* 'defdiagram 'cube <list>))

>   You will hear a lot of whining from people who think eval is evil.
>   Ignore them for now.

>   However, the macro is actually pretty well-behaved, so you can easily do

> (put-diagrem 'cube (construct-diagram (check-diagram <list>)))

>   which should produce the desired results.

> #:Erik

Both works very well.
Thanks alot. =0)

Sungwoo


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Coby Beck  
View profile  
 More options Jul 24 2001, 1:00 pm
Newsgroups: comp.lang.lisp
From: "Coby Beck" <cb...@mercury.bc.ca>
Date: Tue, 24 Jul 2001 16:44:46 GMT
Local: Tues, Jul 24 2001 12:44 pm
Subject: Re: How can I implement a function inside of a list?

"Sungwoo Lim" <sung...@cad.strath.ac.uk> wrote in message

news:240720011009588191%sungwoo@cad.strath.ac.uk...

> Hello,

> Suppose, I have a function TEST as below.

> (defun test (i)
>   (loop for j from 0 to (- i 1)
>         do (print j)))

[off topic]

(- i 1) ==> (1- i)

(loop for j from 0 to (1- i))  ==> (loop for j below i)

just FYI...

Coby

--
(remove #\space "coby . beck @ opentechgroup . com")


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Discussion subject changed to "Thanx. =) (no content)" by Sungwoo Lim
Sungwoo Lim  
View profile  
 More options Jul 24 2001, 1:46 pm
Newsgroups: comp.lang.lisp
From: Sungwoo Lim <sung...@cad.strath.ac.uk>
Date: Tue, 24 Jul 2001 18:45:15 +0100
Local: Tues, Jul 24 2001 1:45 pm
Subject: Thanx. =) (no content)
In article <2Ch77.54443$uo3.9715...@typhoon.tampabay.rr.com>, Coby Beck

<cb...@mercury.bc.ca> wrote:

.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »