13 lines
660 B
Text
13 lines
660 B
Text
listvariant :-
|
|
List = new_list(5), % create a list of length 5
|
|
nth(1,List,a), % put an a at position 1 , nth/3 uses indexing from 1
|
|
nth(4,List,b), % put an b at position 4
|
|
println(list=List),
|
|
append(List,[d],List2), % append an d at the end , List2 has 5 elements
|
|
println(list2=List2),
|
|
Add = new_list(5), % create a new list of length 5
|
|
append(List2,Add,List3), % append 5 free variables to List2
|
|
println(len=List3.len), % List3 now has 11 elements
|
|
println(list3=List3),
|
|
Value = List3[1], % get the value at position 1
|
|
println(value=Value). % will print out a
|