On Mon, Apr 16, 2012 at 02:52:44PM +0200, Ralf Hemmecke wrote:
>> So: I do not understand, generally, how to program in Spad.
>> That is the problem.
>
> Can you confirm that you have studied the Aldor User Guide completely?
> That's in my view the best way to understand SPAD.
I never looked into it.
Now, suppose that I study it. All right, I have heard that Aldor allows
adding categories to the library domains (as any sensible language must).
So, I shall use Aldor and declare the category Show, and then add its
instances to the domains of Integer, Product, List, Fraction, UPol --
similar as I do in Haskell.
May be, it will work (is Aldor workable?).
But this approach is not compiled in Spad.
If it is in Aldor, then how do people use the aimed Haskell interface when
Aldor is not open source, and there are problems with the license?
What shall I do further with this Aldore code?
Again: Bill Page and Waldek wrote that my problem with
parse : String -> Product(T, String)
can be programed by defining certain particular packages.
Now, I replace `parse' with even simpler problem of show : T -> String.
And ask: how to program it for compositions only of the _3_ constructors:
Integer, Product, List. What precisely are these packages?
May be, 20 non-empty line code to demonstrate.
I demonstrate it in Haskell:
-------------------------------------------------------------------
class Show1 a where show1 :: a -> String
--
-- `Show1' is taken to avoid clash with `Show' of the standard library.
-- `::' <-> `:' of Spad, `=' <-> `==', `:=', ':' <-> cons.
-- `a', `b' ... <-> category or a package parameter in Spad.
-- Integer, (,), [] are constructors from the standard library,
-- (a, b) <-> Product(a, b), [a] <-> List a.
instance Show1 Integer where show1 = show
-- use the library operation for Integer
instance (Show1 a, Show1 b) => Show1 (a, b)
-- print from (Pair a b) via printing (show1) for `a' and `b'
where
show1 (x, y) = concat["(", show1 x, "," show1 y, ")"]
instance Show1 a => Show1 [a] -- implementation for List: print from
where -- (List a) via show1 for `a'.
show1 [] = "[]"
show1 (x : xs) = concat [ "[", show1 x, showL xs, "]" ]
where
showL [] = ""
showL (x: xs) = concat ["," show1 x, showL xs]
---------------------------------------------------------------------
-- 12 non-empty lines. Example of usage:
show1 ( [ [(1,2),(3,4)], [(5,6)] ] :: List (List (Pair Integer)) ) =
"[[(1,2),(3,4)],[(5,6)]]"
What is the corresponding code in Spad, what are these (1-3) packages?
Is this so difficult to demonstrate the corresponding may be, 20 line
code?
Regards,
------
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.