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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to simplify a list?

Status
Not open for further replies.

ting138

MIS
Mar 12, 2002
2
0
0
GB
I have a list
[a,b,[c,d,[s,d],[c,d]]]
how can I simplify it down to
[a,b,c,d,s,d,c,d]?
 
maybe......

concat([], Y, Y).
concat([X | XR], Y, [X | Z]) :- concat(XR, Y, Z).

s([], []).
s([X|XR], [X|Y]) :- atomic(X), !, s(XR, Y).
s([X|XR], Y) :- s(X, X2), s(XR, XR2), concat(X2, XR2, Y).

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top