On Tue, Mar 20, 2012 at 07:55:22PM +0100, Ralf Hemmecke wrote:
> What is this?
>
>>    HashTab ==>  HashTable(Key, Val, String)
>
> Have you looked at the documentatio or in the source code?
> [..]

Kind of a typo! Thank you. It must be

------------------------------------------------
HashTab ==> HashTable(Key, Val, hf)

)abbrev package HASHTAB1 HashTable1
HashTable1(Key : SetCategory, Val : SetCategory, hf : String) : with
...
------------------------------------------------

And a package call will set  "EQL", "EQ" ... for  hf.

The improved code is now

-------------------------------------------------------------------
OF   ==> OutputForm
NLOF ==> newline :: OutputForm

)abbrev package HASHTAB1 HashTable1
HashTable1(Key : SetCategory, Val : SetCategory, hf : String) :
                                       Exports == Implementation  where
  MbVal     ==> Union(Val,      "failed")
  MbValList ==> Union(List Val, "failed")
  HashTab   ==> HashTable(Key, Val, hf)
  Exports == with
               searchMany : (List Key, HashTab) -> MbValList
               searchMany : (List Key, HashTab) -> List Val

  Implementation == add

    searchMany(keys : List Key, tab : HashTab) : MbValList ==

          -- returns "failed"  iff  any of  keys  is not in  tab

          mbs : List MbVal := map(k +-> search(k, tab), keys)
                                             $ListFunctions2(Key, MbVal)
          any?(x +-> x case "failed", mbs) => "failed"
          map(x +-> x :: Val, mbs) $ListFunctions2(MbVal, Val)

    searchMany(keys : List Key, tab : HashTab) : List Val ==

          -- breaks   iff  any of  keys  is not in  tab
          msg() : Void ==
                       oF := hconcat["searchMany ", coerce(keys) :: OF,
                                       NLOF, " tab :"]
                       print(oF)$OF

          mbL : MbValList := searchMany(keys, tab)
          mbL case "failed" =>
                          (msg(); error "some key is not in the table.")
          mbL :: List Val
--------------------------------------------------------------------

-- not run, so far.
Thanks to Waldek: 
now I set            MbVal     ==> Union(Val,      "failed")
                     MbValList ==> Union(List Val, "failed")
                     HashTab   ==> HashTable(Key, Val, hf)
as local, to the needed place.

There remains the following question about the compiler
-------------------------------------------------------

Replace  HashTable(Key, Val, hf)  with  HashTable(Key, Val, String).

This latter contradicts the definition of  HashTable,  because  
String : SetCategory   does not belong to  String.
Still the changed code is compiled without any error message. 
-- ?

A minor point:
other .spad files use  NLOF ==> newline() :: OutputForm, 
and it works there.
But in this  t.spad  -- its usage is not compiled, I was forced to
change it to  
             NLOF ==> newline :: OutputForm

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.

Reply via email to