Serge D. Mechveliani wrote:
>
> To my
>
> >> Has the library a function that breaks a string to the Spad lexemes?
> >> In DoCon, I use the Haskell lexemes for this and the corresponding
> >> library function for breaking to lexemes (and this also defines what
> >> is a lexeme).
>
> Waldek Hebish wrote
>
> > You may with to look at Lisp function READ-FROM-STRING. One can
> > use it to convert string into arbitrary Lisp data. In particular
> >
> > (1) -> READ_-FROM_-STRING("(|powerProduct| 4 1 2)")$Lisp
> >
> > (1) (powerProduct 4 1 2) : SExpression
>
> > that is you may easily get list of whatever entries you need.
> > The return type of calls to Lisp function is SExpression, but one
> > can convert it to apropriate type.
>
>
> 1. I guess, `$Lisp' is a package calling.
> And Browse - Lisp - packages reports that there is no package
> named Lisp.
`$Lisp' means calling builtin functions, currently written in Lisp
or Boot. Such functions do not show in browser.
> 2. READ_-FROM_-STRING("cons (I 23) cons (I 12) NIL")$Lisp
> yields
> CONS Type: SExpression
>
> But how to part the remaining lexemes?
> Rather the result needs to be
>
> [CONS, "(I 23) cons (I 12) NIL"]
> Type: Product(SExpression, String).
> Am I missing something?
Yes. READ_-FROM_-STRING has its own syntax -- acutally this is
syntax of Lisp S-expressions. S-expressions where designed to
be both human readable and easy to parse. READ_-FROM_-STRING
parses first S-expression contained in the argument string
(if it can not find any complete S-expression it signal error).
The examlpe I gave illustrates how you can pass list of items
as a single S-expression. In your case "cons" is valid
S-expression so that is all what you get. BTW, by default
READ_-FROM_-STRING upcases input symbols. To preserve case
the simplest way it to put symbols inside vertical bars, as
in my example (if you use Lisp other than GCL you can easily
disable upcasing at Lisp level, but it is not easy form Spad).
My point is that if you can live with the syntax imposed by
READ_-FROM_-STRING then it gives you reasonably efficient
method to get from string to list (or tree) of items.
> 3. It is desirable to have a _function from the standard Axiom library_
> (hence, and a documented one).
<snip>
> In this sense, how reliable are READ_-FROM_-STRING, and other items
> from the Lisp package?
> Where to find the description for these items?
READ_-FROM_-STRING (in Lisp actually READ-FROM-STRING) is part
of Common Lisp -- it will be there as long as FriCAS runs on
top of Common Lisp. You can find its description at:
http://www.lispworks.com/documentation/HyperSpec/Body/f_rd_fro.htm
If you follow links from that page and carefully read description
of the syntax you will find that the complete language implemented
by READ-FROM-STRING has several "interesting" possiblities.
Once FriCAS is ported to virtual machine different than Lisp
Lisp READ-FROM-STRING will be no longer available. In such
case we will probably implement a simple version which handles
lists, integers, symbols and strings (maybe also machine floats)
but not much more. And you can expect change of name in such case.
Note: simple version of READ-FROM-STRING can be implemented in
about 200 lines of code (you can find a C version in
'src/etc/asq.c.pamphlet').
--
Waldek Hebisch
[email protected]
--
You received this message because you are subscribed to the Google Groups
"FriCAS - computer algebra system" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/fricas-devel?hl=en.