[mercury-users] Dispatch tables? Curried functions?
Douglas Michael Auclair
dauclair at hotmail.com
Wed Jun 5 14:18:11 AEST 2002
Hello, all,
I wish to create a map that has string keys and function values to use as a
dispatch table. The problem I have is that predicate lookup/3 returns the
function in the ground state, not the state of the function (e.g.:
func((ground -> ground), (ground -> ground)) = (free -> ground)) -- the
function lookup also returns the function in the undesired ground state.
I worked around this by creating a top-level predicate with the appropriate
type qualifications (see next paragraph). Is that the only way to go? Is
it possible to create dispatch tables using maps? How would this be done?
Another issue: the documentation is clear on how to create predicates that
return predicates (by declaring the out parameter as type (e.g.) free ->
pred(in, out) is det). But I'm not getting the syntax for predicates or
functions that return functions: free -> func(int) = int doesn't work, nor
does free -> (func(int) = int). What is the proper mode/instantiation for a
function that returns a function?
My work-around for this one is to package the function to be curried into a
locally declared predicate, call a predicate that returns the curried
predicate, and then unpackage that new predicate into a local function.
Quite a bother! Is there a one-step way of currying functions?
Sincerely,
Doug Auclair
_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.com
--------------------------------------------------------------------------
mercury-users mailing list
post: mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the users
mailing list