Serge D. Mechveliani wrote:
>
> People,
>
> I thank Ralf Hemmecke for explanations.
>
> I look into the book, and use the Axiom brouser. And still it is
> difficult to find some simple constructs.
> I have the following beginner questions.
>
> 1. Where can be found simple examples of Spad programs?
> For example, in Haskell, the Standard Library description is full
> of such examples. They are the meaning definitions,
> and also Haskell program examples,
> and most often, they are also efficient implementation.
>
Chapters 11, 12 and 13 of Axiom book (visible in HyperDoc).
Note that the main difference between interpreter language
and Spad is that in you can not have "standalone" function
and need to put it in a domain, package or category. So
most examples of interpreter programs are valid _parts_
of Spad programs.
>
> 2. What Spad has for the Direct Product of (different) types?
>
Currently buitin Record (arbitrary mant factors, only few
operatios) and Product (two factors, inherits some structure
from factrs).
> 3. List Character vs String
>
> Haskell puts type String = [Char]
>
> -- a string is a list of characters.
> For example,
> "ab;c\nd" === ['a', 'b', ';', 'c', '\n', 'd'].
>
> Due to this, most of the functions for String are done by generic
> functions for the types
> forall a => [a], (Eq a) => [a], (Ord a) => [a].
>
> I hope to program strings in Spad by using the conversion
> String <--> List Character.
> For `-->', I find `entries' in "String", "operations".
> Does it fit?
> And what is for `<--' ?
>
String is an exaple of Collection, and you can construct collections
from parts using 'construct' operation. Usually 'construct' is
abbreviated to just square brackets:
(11) -> construct(members("John"))$String
(11) "John"
Type: String
(12) -> [members("John")]$String
(12) "John"
Type: String
Note that in Spad generic functions work on Collections, so you
should be able to do most of processing without convertiong to
lists.
I am not sure if converting string to lists is good idea. It
may help if you want to some hairy manipulations, but otherwise
working on strings directly should be easier. And if you need
to make something fast, then using array may give you significant
speedup (for example you can index strings in O(1) time, but
indexing lists is O(n)).
--
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.