seeking retrieve the value of an argument irrespective of functor

Discussions related to Visual Prolog
daveplummermd
VIP Member
Posts: 87
Joined: 18 Jul 2006 17:18

seeking retrieve the value of an argument irrespective of functor

Unread post by daveplummermd » 19 Apr 2018 20:08

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
Dave Plummer

User avatar
Thomas Linder Puls
VIP Member
Posts: 2407
Joined: 28 Feb 2000 0:01

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

Unread post by Thomas Linder Puls » 19 Apr 2018 21:35

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.
Regards Thomas Linder Puls
PDC

daveplummermd
VIP Member
Posts: 87
Joined: 18 Jul 2006 17:18

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

Unread post by daveplummermd » 19 Apr 2018 22:13

thanks
your right
dp
Dave Plummer

Post Reply