1
我不知道,如果這叫做currying,但是我想要一個HashMap(String,Long,Short,String);Ada HashMap in HashMap
蚋編譯器抱怨:
main.adb:20:13: warning: possible infinite recursion
main.adb:20:13: warning: Storage_Error may be raised at run time
main.adb:24:13: warning: possible infinite recursion
main.adb:24:13: warning: Storage_Error may be raised at run time
什麼是寫在這裏的「=」功能正確的方法是什麼?
main.adb
with Ada.Containers.Indefinite_Hashed_Maps;
with Ada.Strings.Hash;
with Ada.Text_IO;
procedure Main is
subtype Short is Short_Integer;
subtype Long is Long_Integer;
function Hash (X : String) return Ada.Containers.Hash_Type is
(Ada.Strings.Hash (X));
function Hash (X : Short) return Ada.Containers.Hash_Type is
(Ada.Containers.Hash_Type'Mod (X));
function Hash (X : Long) return Ada.Containers.Hash_Type is
(Ada.Containers.Hash_Type'Mod (X));
package Short_String_Map is new Ada.Containers.Indefinite_Hashed_Maps (Short, String, Hash, "=");
function "=" (Left, Right : Short_String_Map.Map) return Boolean is
(Left = Right);
package Long_Short_Map is new Ada.Containers.Indefinite_Hashed_Maps (Long, Short_String_Map.Map, Hash, "=");
function "=" (Left, Right : Long_Short_Map.Map) return Boolean is
(Left = Right);
package String_Long_Map is new Ada.Containers.Indefinite_Hashed_Maps (String, Long_Short_Map.Map, Hash, "=");
begin
-- Map(String, Long, Short, String);
null;
end Main;