Arrays: Difference between revisions
Content added Content deleted
m (→{{header|Picat}}: Added {{out}} and {{trans}}) |
|||
Line 5,888: | Line 5,888: | ||
</lang> |
</lang> |
||
{{out}} |
|||
Output: |
|||
⚫ | |||
<pre> |
|||
⚫ | |||
a = {1,0,0,0,0,0,0,0,0,0} |
a = {1,0,0,0,0,0,0,0,0,0} |
||
a1 = 1 |
a1 = 1 |
||
Line 5,907: | Line 5,905: | ||
a3 = {11,102,1003,10004} |
a3 = {11,102,1003,10004} |
||
[first = 11,second = 102,last = 10004] |
[first = 11,second = 102,last = 10004]</pre> |
||
</pre> |
|||
{{trans|Prolog}} |
|||
This was inspired by the Prolog example showing how lists can be used. |
|||
<lang Picat>listvariant:- |
<lang Picat>listvariant :- |
||
List = new_list(5), % create a list of length 5 |
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(1,List,a), % put an a at position 1 , nth/3 uses indexing from 1 |
||
Line 5,927: | Line 5,923: | ||
</lang> |
</lang> |
||
{{out}} |
|||
("_4970" etc are undefined variables): |
|||
<pre> |
<pre> |
||
list = [a,_4970,_4980,b,_49a0] |
list = [a,_4970,_4980,b,_49a0] |
||
Line 5,933: | Line 5,930: | ||
len = 11 |
len = 11 |
||
list3 = [a,_4970,_4980,b,_49a0,d,_4e50,_4e60,_4e70,_4e80,_4e90] |
list3 = [a,_4970,_4980,b,_49a0,d,_4e50,_4e60,_4e70,_4e80,_4e90] |
||
value = a |
value = a</pre> |
||
</pre> |
|||
=={{header|PicoLisp}}== |
=={{header|PicoLisp}}== |