{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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

This preview shows pages 1–5. Sign up to view the full content.

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.

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

View Full Document
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 - output argument
Quagent Prolog API Low level quagent interface q_connect(+Host,-QuagentDesc)/2 q_connect(-QuagentDesc)/1

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern