Page 1 of 1

seeking retrieve the value of an argument irrespective of functor

Posted: 19 Apr 2018 20:08
by daveplummermd
Hello
I am seeking a way to retrieve the value of an argument irrespective of it's functor.

I have a domain for attributes of a person:

Code: Select all

personAtr =         last(string);         first(string);         .....         hundredslater(string).        
every attribute has a functor (last, first.....hundredslater) , and a single arity argument that is always a string.

I could retrieve that string value by:

Code: Select all

class predicates     get_memberValue : (personAtr) -> string. clauses     get_memberValue(last(Value)) = Value :-         !.     get_memberValue(first(Value)) = Value :-         !.         ....              get_memberValue(hundredslater(Value)) = Value :-         !.        
but this requires one for each funtor....
OR

I am seeking magic predicate/function that behaves like this:

Code: Select all

get_value_with_magic_arg_extractor(Arg)=Value:-        
where Value is the string that is containing in the argument irrespective of functor.

Is there such a technique?

thanks in advance

dave

Re: seeking retrieve the value of an argument irrespective of functor

Posted: 19 Apr 2018 21:35
by Thomas Linder Puls
I wouldn't advice to try something like that. But if the domain really consist of a huge number of functors all with a single string argument, then it might be more practical to use a domain like this:

Code: Select all

domains     personAtr = personAtr(personAtrKind Kind, string Value).     personAtrKind = last; first; ...; hundresLater.
And then it will be easy to obtain the Value.

Re: seeking retrieve the value of an argument irrespective of functor

Posted: 19 Apr 2018 22:13
by daveplummermd
thanks
your right
dp