From: ab talebi
Subject: variable in Lisp
Date: 
Message-ID: <3c46ea50.5171644@news.uio.no>
I have written some functions that work just fine, so when I evaluate
this sentence:
(mapcar #'car (cadr (parse-it (caar (get-info "car")))))

it will give me: (engine tire gear-box)

now I want to make a function that allows me to get-info for more
things so I wrote:

(defun give-information (topic)
(mapcar #'car (cadr (parse-it (caar (get-info topic))))))

the idea is that it should give me info about any topic. but it gives
me: 
Error: In a call to ARRAY-ELEMENT-TYPE: NIL is not of type ARRAY.

(get-info) is a kind of function that takes a string as element

tnx

ab talebi

From: Nils Goesche
Subject: Re: variable in Lisp
Date: 
Message-ID: <a26r3o$uqve7$1@ID-125440.news.dfncis.de>
In article <················@news.uio.no>, ab talebi wrote:
> the idea is that it should give me info about any topic. but it gives
> me: Error: In a call to ARRAY-ELEMENT-TYPE: NIL is not of type ARRAY. 
> 
> (get-info) is a kind of function that takes a string as element

Learn to use your debugger.  Let him show you a backtrace when the
error occurs.

Regards,
-- 
Nils Goesche
"Don't ask for whom the <CTRL-G> tolls."

PGP key ID 0x42B32FC9
From: Christopher Stacy
Subject: Re: variable in Lisp
Date: 
Message-ID: <usn94c2na.fsf@spacy.Boston.MA.US>
>>>>> On Thu, 17 Jan 2002 15:23:03 GMT, ab talebi ("ab") writes:

 ab> I have written some functions that work just fine, so when I evaluate
 ab> this sentence:
 ab> (mapcar #'car (cadr (parse-it (caar (get-info "car")))))

 ab> it will give me: (engine tire gear-box)

 ab> now I want to make a function that allows me to get-info for more
 ab> things so I wrote:

 ab> (defun give-information (topic)
 ab> (mapcar #'car (cadr (parse-it (caar (get-info topic))))))

 ab> the idea is that it should give me info about any topic. but it gives
 ab> me: 
 ab> Error: In a call to ARRAY-ELEMENT-TYPE: NIL is not of type ARRAY.
 ab> (get-info) is a kind of function that takes a string as element

The variable TOPIC does not contain what you expect.
From: ab talebi
Subject: Re: variable in Lisp
Date: 
Message-ID: <3c48109e.3220095@news.uio.no>
On Thu, 17 Jan 2002 17:23:37 GMT, Christopher Stacy
<······@spacy.Boston.MA.US> wrote:

>>>>>> On Thu, 17 Jan 2002 15:23:03 GMT, ab talebi ("ab") writes:
>
> ab> I have written some functions that work just fine, so when I evaluate
> ab> this sentence:
> ab> (mapcar #'car (cadr (parse-it (caar (get-info "car")))))
>
> ab> it will give me: (engine tire gear-box)
>
> ab> now I want to make a function that allows me to get-info for more
> ab> things so I wrote:
>
> ab> (defun give-information (topic)
> ab> (mapcar #'car (cadr (parse-it (caar (get-info topic))))))
>
> ab> the idea is that it should give me info about any topic. but it gives
> ab> me: 
> ab> Error: In a call to ARRAY-ELEMENT-TYPE: NIL is not of type ARRAY.
> ab> (get-info) is a kind of function that takes a string as element
>
>The variable TOPIC does not contain what you expect.

I understand that. this is general question

if we have a function (like get-info) that takes a string as argument,
how can we write another fuction (give-information) that takes an
argument and passes it to get-info as a string. Does give-information
have to take its argument as a string too?

tnx
ab talebi
From: Thomas A. Russ
Subject: Re: variable in Lisp
Date: 
Message-ID: <ymik7ufmmtv.fsf@sevak.isi.edu>
············@yahoo.com (ab talebi) writes:
> I understand that. this is general question
> 
> if we have a function (like get-info) that takes a string as argument,
> how can we write another fuction (give-information) that takes an
> argument and passes it to get-info as a string. Does give-information
> have to take its argument as a string too?

Well, you simply write the GIVE-INFORMATION function and use whatever
method is appropriate to coerce the incoming argument into a string.
Exactly how you do that would, in general, be application dependent.
However, you might find the TYPECASE form to be of value.

An alternate approach would be to make GET-INFO be a generic function
and write methods for the various types of arguments for it:

(defmethod get-info ((key STRING))  ... do what you do now ...)
(defmethod get-info ((key SYMBOL))  (get-info (symbol-name key)))
   ;; Note that in this case, the string will generally be in UPPERCASE



> 
> tnx
> ab talebi

-- 
Thomas A. Russ,  USC/Information Sciences Institute          ···@isi.edu    
From: Barry Margolin
Subject: Re: variable in Lisp
Date: 
Message-ID: <1_X18.34$Gk3.148821@burlma1-snr2>
In article <················@news.uio.no>,
ab talebi <············@yahoo.com> wrote:
>On Thu, 17 Jan 2002 17:23:37 GMT, Christopher Stacy
><······@spacy.Boston.MA.US> wrote:
>
>>>>>>> On Thu, 17 Jan 2002 15:23:03 GMT, ab talebi ("ab") writes:
>>
>> ab> I have written some functions that work just fine, so when I evaluate
>> ab> this sentence:
>> ab> (mapcar #'car (cadr (parse-it (caar (get-info "car")))))
>>
>> ab> it will give me: (engine tire gear-box)
>>
>> ab> now I want to make a function that allows me to get-info for more
>> ab> things so I wrote:
>>
>> ab> (defun give-information (topic)
>> ab> (mapcar #'car (cadr (parse-it (caar (get-info topic))))))
>>
>> ab> the idea is that it should give me info about any topic. but it gives
>> ab> me: 
>> ab> Error: In a call to ARRAY-ELEMENT-TYPE: NIL is not of type ARRAY.
>> ab> (get-info) is a kind of function that takes a string as element
>>
>>The variable TOPIC does not contain what you expect.
>
>I understand that. this is general question
>
>if we have a function (like get-info) that takes a string as argument,
>how can we write another fuction (give-information) that takes an
>argument and passes it to get-info as a string. Does give-information
>have to take its argument as a string too?

Of course.  Since it just passes it on to GET-INFO, the argument it
receives has to be valid for the function it sends it to.

-- 
Barry Margolin, ······@genuity.net
Genuity, Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
From: Coby Beck
Subject: Re: variable in Lisp
Date: 
Message-ID: <e6E18.20540$_w.2714471@typhoon.tampabay.rr.com>
"ab talebi" <············@yahoo.com> wrote in message
·····················@news.uio.no...
> I have written some functions that work just fine, so when I evaluate
> this sentence:
> (mapcar #'car (cadr (parse-it (caar (get-info "car")))))
> the idea is that it should give me info about any topic. but it gives
> me:
> Error: In a call to ARRAY-ELEMENT-TYPE: NIL is not of type ARRAY.
>
> (get-info) is a kind of function that takes a string as element

As other suggested, use your debugger.  If you still need help, you have to
show us the source AND a session in the listener that makes this happen.

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