Juts Posted March 17, 2009 Share Posted March 17, 2009 Hey, I've been going through the website LearnPrologNow! (learnprolognow.org) And i've come across a problem that's got me stumped. ----------------------------------------------------------------------------------------- Write a predicate addone2/ whose first argument is a list of integers, and whose second argument is the list of integers obtained by adding 1 to each integer in the first list. For example, the query addone([1,2,7,2],X). should give X = [2,3,8,3]. --------------------------------------------------------------------------------------------- Any advice and or.....solutions :D Link to comment Share on other sites More sharing options...
0 cx323 Posted March 17, 2009 Share Posted March 17, 2009 addone2([ ],[ ]). addone2([HIn | TIn],[HIn + 1 | TOut]) :- addone2(TIn,TOut). Link to comment Share on other sites More sharing options...
Question
Juts
Hey, I've been going through the website LearnPrologNow! (learnprolognow.org) And i've come across a problem that's got me stumped.
-----------------------------------------------------------------------------------------
Write a predicate addone2/ whose first argument is a list of integers, and whose
second argument is the list of integers obtained by adding 1 to each integer in
the first list. For example, the query
addone([1,2,7,2],X).
should give
X = [2,3,8,3].
---------------------------------------------------------------------------------------------
Any advice and or.....solutions :D
Link to comment
Share on other sites
1 answer to this question
Recommended Posts