ln011 - The Average Program Example: write a program that...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: The Average Program Example: write a program that asks the user for a list of integers, reads this list of integers from the terminal and computes the average value of the list. lcount(,0). lcount([_|T],C) :- lcount(T,C1), C is 1 + C1. ladd(,0). ladd([X|T],S) :- ladd(T,S1), S is X + S1. ave(S,C,A) :- A is S/C. lave(L,A) :- ladd(L,S),lcount(L,C),ave(S,C,A). interact :- write('Enter a list> '), read(L), lave(L,A), write('The average is '), write(A), nl, nl, interact. Quagent Prolog API High level quagent interface Action: q_walk(+Quagent,+Distance)/2 q_turn(+Quagent,+Angle)/2 q_pickup(+Quagent,+Item)/2 q_drop(+Quagent,+Item)/2 Perception: q_radius(+Quagent,+Radius)/2 q_rays(+Quagent,+No_of_Rays)/2 q_cameraon(+Quagent)/1 q_cameraoff(+Quagent)/1 Proprioception: q_where(+Quagent)/1 q_inventory(+Quagent)/1 q_wellbeing(+Quagent)/1 Events: q_events(+Quagent,-[Events])/2 Note: + input argument Quagent Prolog API High level quagent interface Action: q_walk(+Quagent,+Distance)/2 q_turn(+Quagent,+Angle)/2...
View Full Document

This note was uploaded on 10/03/2011 for the course CSC 592 taught by Professor Staff during the Spring '11 term at Rhode Island.

Page1 / 5

ln011 - The Average Program Example: write a program that...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online