countall.pl

loading
details
attribute value
description
owner Johannes Waldmann
uploaded 2017-08-17 03:45:08.0
disk size 584 Bytes
downloadable true
type
attribute value
name no_type
processor id 1
description this is the default benchmark type for rejected benchmarks and benchmarks that are not associated with a type.
owning community none
loading contents
%Source: http://research.cs.queensu.ca/home/cisc260/2015w/examples/Arithmetic.pl
%query:countAll(g,g,f).
countAll(Item,[],0).
countAll(Item,Other,1) :-
	atomic(Other),
	% In class, we discussed adding Other\=[], but this is
	% not necessary, because Item will not be a list and so
	% will never be equal to []. 
	Other = Item.
countAll(Item,Other,0) :-
	atomic(Other),
	Other \= [], % In this rule, this goal prevents duplicate correct answers.
	Other \= Item.
countAll(Item,[X|Xs],Result) :-
	countAll(Item,X,HeadCount),
	countAll(Item,Xs,TailCount),
	Result is HeadCount+TailCount.
popout

content may be truncated. 'popout' for larger text window.

actions get anonymous link download benchmark