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 can i found out the first 3 element of a list?

Status
Not open for further replies.

kenguru

Programmer
May 14, 2004
173
RO
Hi!

I'm making a little test program in Clean, I know that this forum isn't about this programing language but i though if someone knows prolog maybe he worked in clean to:)
It is possible someway to find out the first x element of a list. For example if we have: [1 2 3 4 5] and x=2 than i would like to have as a result [1 2]

Thank's to those who read my question,
Kenguru
 
Hi.. you could try the following...

firstalst(0,_,[]).
firstalst(A,[X|U],[B|Z]) :- A1 is A-1,B is X,firstalst(A1,U,Z).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top