Re: Generic term search in a list



Jan Wielemaker <jan@xxxxxxxxxxxxxxxxxxx> writes:
> What about
>
> get_range(options(Options), Range) :-
> Range = range(_, ),
> ( memberchk(Range, Options)
> -> true
> ; Range = range(0,inf)
> ).

Aha, memberchk. Looks good. Thanks.


> I see little purpose in the options/1 representation and would use a
> plain list.

I do such things often for readability. Less for the definition
of the predicates but mostly when they are called. I prefer

get_d(options([range(1,2), foo(12), bar(65)]), depends(B,C), D)

over

get_d([range(1,2), foo(12), bar(65)], depends(B,C), D)


I'm still learning typical patterns and are experimenting to find my
personal style. Would you consider the above as unusual style in
Prolog?

Thanks.

Steffen
--
Steffen Schwigon <schwigon@xxxxxxxx>
Dresden Perl Mongers <http://dresden-pm.org/>
.