Teen Programmers Unite  
 

 

Return to forum top

Prolog help

Posted by Clark [send private reply] at February 20, 2002, 07:04:11 AM

Hi!

Want help with some Prolog assignments:

1. Find the maximum and minimum in a list of numbers.

2. Find out if a given predicate is a member of a list, ex. member(X,L) checks if X is part of list L.

How do I start? Any ideas?

Thank you

/Clark

Posted by metamorphic [send private reply] at February 20, 2002, 07:43:25 AM

im not going to do your assignments for you, but i will give you some help. I didnt know there was a language called prolog (someone tell me what it is please!) but for the maximum and minimum values in a list, use an array (im assuming it has arrays) and use 2 loops one for min value and one for max. then just look through each value in turn and see if its the smallest (or greatest) value that its found so far.

Marc

Posted by Clark [send private reply] at February 20, 2002, 09:06:30 AM

Sorry, but Prolog is not for humans and doesn't have easy control structures as in C or Pascal. It's a locical programming language and you just use logical statements and ask them questions and get (un)logical answers.

Thanks anyway!

/Clark

Posted by metamorphic [send private reply] at February 20, 2002, 10:29:06 AM

<shock><horror>no</horror> control structures?</shock> i know you didnt say it was a programming lanugage, but without control structures such as if, else, for, while, loop, goto, switch, functions/ subroutines ect.. could it be classed as a programming language?

if your talking about logical statments do you mean things like (x AND y) or (NOT x) ect? If so, wouldnt finding the min and max just requires a few comparisons?

Posted by CodeRed [send private reply] at February 20, 2002, 12:38:46 PM

I made a clock (h/m/s) using a constant power supply, about a thousand transistors, and a 6 digit LCD display. One of the most difficult things I've ever done.

Posted by Clark [send private reply] at February 21, 2002, 06:56:18 AM

Congrats CodeRed! Always fun to hear someone succeeding with something ... :)

Posted by RedX [send private reply] at February 21, 2002, 11:48:20 AM

You could have done the same thing with a few counters and a oscilator as timebase. If I think about all the holes you had to drill, I remember why the IC is man's best friend
(That is if you used a PCB).

RedX

Posted by sphinX [send private reply] at February 21, 2002, 04:40:15 PM

I've never actually gotten to the point of *making* my logic circuits. I design the whole thing on paper, optimise my gate usage and make it real pretty (ie complicated and obtuse) ... then I get bored :-)

Posted by RedX [send private reply] at February 22, 2002, 11:35:36 AM

I've designed and build my share of PCB's. I usualy design something in my head. Then draw it, and fill in the details (bypass caps', resistor values, etc) and do some optimising. I don't use much logic gates, mainly ýcontrollers (small, cheap, relieable, reprogramable, what more could you wish). Although I did use a AND-port to modulate serial data on a 36Khz carrier for IR-communication on one of my latest designs.

RedX

You must be logged in to post messages and see which you have already read.

Log on
Username:
Password:
Save for later automatic logon

Register as a new user
 
Copyright TPU 2002. See the Credits and About TPU for more information.