how to pass a list in clisp command line as a argument? 
Author Message
 how to pass a list in clisp command line as a argument?


Quote:
>Hi, I want to know how to past a list as argument to a LISP program?

>assume my program is foo.lsp
>how can I pass it a list like '(a b)?

>clisp foo.lsp '(a b)        doesn't work.

>And how to get and use the arguments in my program?

Assume foo.lsp looks like:
(format t "Args: ~a~%" user::*args*)

$ clisp foo.lsp "'(a b)"
Args: ('(a b))
$

user::*args* is a list of the arguments given (last) on the
command line. I think it is documented in implementation.html

--
------------------------------------------------------------------



Wed, 22 May 2002 03:00:00 GMT  
 how to pass a list in clisp command line as a argument?

+---------------

| >clisp foo.lsp '(a b)      doesn't work.
| >how can I pass it a list like '(a b)?
...
| user::*args* is a list of the arguments given (last) on the
| command line. I think it is documented in implementation.html
+---------------

Yup, it's documented both in the man page and in more detail in the
implementation notes, "Extensions-2.8. Quickstarting delivery with CLISP":
http://clisp.cons.org/~haible/documentation/clisp/doc/clisp.html
http://clisp.cons.org/~haible/documentation/clisp/doc/impnotes.html#q...

But if he wants to end up with actual lists (or other Lisp forms), then
he probably also wants to use READ-FROM-STRING, since *ARGS* is a list of
strings, only. For example:

        % cat foo
        #!/usr/local/bin/clisp
        (mapc #'print
          (mapcar #'eval
            (mapcar #'read-from-string *args*)))
        % foo "'(a b)" "'(+ 23 45)" "(+ 23 45)"
        (A B)
        (+ 23 45)
        68
        %

-Rob

p.s. If you can't use the "#!" hack for some reason,
it's also usable this way:

        % clisp foo "'(a b)" "'(+ 23 45)" "(+ 23 45)"
        (A B)
        (+ 23 45)
        68
        %

-----

Applied Networking              http://reality.sgi.com/rpw3/
Silicon Graphics, Inc.          Phone: 650-933-1673
1600 Amphitheatre Pkwy.         FAX: 650-933-0511
Mountain View, CA  94043        PP-ASEL-IA



Sat, 25 May 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. how to pass command line argument

2. How can I pass arguments from command line ?

3. Passing command line arguments

4. Howto pass command line arguments

5. Passing Command Line Arguments

6. Passing command line arguments

7. How does one pass Unicode command line arguments to Tcl program (Windows 2000)

8. passing arguments to an application from the command-line

9. Passing command line arguments with Tcl_EvalFile

10. Passing command line arguments when debugging with IDLE

11. passing arguments in command line

12. Question on passing strings as command line arguments

 

 
Powered by phpBB® Forum Software