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.


2. What Spad has for the Direct Product of (different) types?

For example, in Haskell, I write
                       
    span   :: (a -> Bool) -> [a] -> ([a], [a]),
    zipRem :: [a] -> [a] -> ([a], [a], [a]).  

Here `a' denotes       any type (a parameter),
  (a -> Bool)          is the type of functions from  a  to Bool,
  [a]  === List a      is the type of lists over  a, 
  ([a], [a])  === Pair [a] [a]
                       is the  direct product  of the two list types,
(a, b, c)  is the  direct product  of the three free types,
For example,  
  ("bc", 2, 'd')  is a triple which is an element of the type
                                              (String, Integer, Char),
  the second member can be extracted by an anonymous function as 
                         (\ (_, y, _) -> y),
  and it can be set as   (\ y' (x, y, z) -> (x, y', z)).

Which are the corresponding type constructors and data operations in 
Spad ? 
Thus, I tried for `span' the code

  )abbrev package MY-LIST MyList 
  MyList(T : Type) : with
    span : (T -> Boolean) -> List T -> DirectProduct(2, List T)  
      == 
       add
         span p xs ==
                empty? xs => ([], xs)
                ...

But, probably,  DirectProduct  and  `([], xs)'  is not the point ...


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  `<--'  ?

Thank you in advance for explanation,

------
Sergei
[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.

Reply via email to