Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how do i duplicate items in a list?

Status
Not open for further replies.

invalid6363

Programmer
Mar 21, 2008
24
US
i need help on how to write a predicate that will duplicate the items in a list, where the left argument is a list and whose right argument is a list consisting of every element in the left list written twice.
 
never mind i got it.

dups([],[]).
dups([H|T],[H,H|Y]) :- dups(T,Y).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top