GNU Prolog - Seems very simple
-
Didn't know where else to post this because prolog doesn't have its own forum. Since it is part of GNU I decided to give this forum a shot. I have a program and need to show that i can run the correct Queries...Having no knowledge of syntax i can't really understand any tutorials. Heres the program.. d(iron, steam). d(pumps, mines). d(mines, railroads). d(iron, railroads). d(iron, guns). d(electricity, aluminum). d(iron, electricity). d(aluminum, jumbojet). d(writing, printingpress). d(printingpress, comicbook). d(iron, printingpress). d(aluminum, printingpress). depends(X,Y) :- d(X,Y). depends(X, Y) :- d(X, Z), depends(Z, Y). Here are the questions... What do you need to invent the comic book? What do you need to invent electricity? If you don't have steam engines, what can you not invent? Given aluminum and electricity, what can you invent? Which inventions are dependent on iron?
-
Didn't know where else to post this because prolog doesn't have its own forum. Since it is part of GNU I decided to give this forum a shot. I have a program and need to show that i can run the correct Queries...Having no knowledge of syntax i can't really understand any tutorials. Heres the program.. d(iron, steam). d(pumps, mines). d(mines, railroads). d(iron, railroads). d(iron, guns). d(electricity, aluminum). d(iron, electricity). d(aluminum, jumbojet). d(writing, printingpress). d(printingpress, comicbook). d(iron, printingpress). d(aluminum, printingpress). depends(X,Y) :- d(X,Y). depends(X, Y) :- d(X, Z), depends(Z, Y). Here are the questions... What do you need to invent the comic book? What do you need to invent electricity? If you don't have steam engines, what can you not invent? Given aluminum and electricity, what can you invent? Which inventions are dependent on iron?
try this: ?- depends(X,comicbook) ?- depends(X,electricity) (no clue about "If you don't have steam engines, what can you not invent?") :doh: ?- depends(aluminum, Y), depends(electricity,X) ?- depends(iron,Y) PS: I assume that depends(X,Y) means that, with X, you can make Y
modified on Tuesday, April 14, 2009 11:53 AM