Minimum numbers of three lists: Difference between revisions
Content added Content deleted
m (→{{header|Factor}}: fix imports) |
(Add Plain English) |
||
Line 223: | Line 223: | ||
{{out}} |
{{out}} |
||
<pre> 5 22 12 21 38</pre> |
<pre> 5 22 12 21 38</pre> |
||
=={{header|Plain English}}== |
|||
<lang plainenglish>To run: |
|||
Start up. |
|||
Create a first list and a second list and a third list. |
|||
Find a minimum list (element-wise) of the first list and the second list and the third list. |
|||
Destroy the first list. Destroy the second list. Destroy the third list. |
|||
Write the minimum list on the console. |
|||
Destroy the minimum list. |
|||
Wait for the escape key. |
|||
Shut down. |
|||
An entry is a thing with a number. |
|||
A list is some entries. |
|||
To add a number to a list: |
|||
Allocate memory for an entry. |
|||
Put the number into the entry's number. |
|||
Append the entry to the list. |
|||
To create a first list and a second list and a third list: |
|||
Add 5 to the first list. |
|||
Add 45 to the first list. |
|||
Add 23 to the first list. |
|||
Add 21 to the first list. |
|||
Add 67 to the first list. |
|||
Add 43 to the second list. |
|||
Add 22 to the second list. |
|||
Add 78 to the second list. |
|||
Add 46 to the second list. |
|||
Add 38 to the second list. |
|||
Add 9 to the third list. |
|||
Add 98 to the third list. |
|||
Add 12 to the third list. |
|||
Add 98 to the third list. |
|||
Add 53 to the third list. |
|||
To find a minimum number of a number and another number: |
|||
If the number is less than the other number, put the number into the minimum; exit. |
|||
Put the other number into the minimum. |
|||
To find a minimum list (element-wise) of a list and another list and a third list: |
|||
Get an entry from the list. |
|||
Get another entry from the other list. |
|||
Get a third entry from the third list. |
|||
Loop. |
|||
If the entry is nil, exit. |
|||
Find a minimum number of the entry's number and the other entry's number. |
|||
Find another minimum number of the third entry's number and the minimum number. |
|||
Add the other minimum number to the minimum list. |
|||
Put the entry's next into the entry. |
|||
Put the other entry's next into the other entry. |
|||
Put the third entry's next into the third entry. |
|||
Repeat. |
|||
To write a list on a console; |
|||
To write a list to a console: |
|||
Get an entry from the list. |
|||
Loop. |
|||
If the entry is nil, write "" on the console; exit. |
|||
Convert the entry's number to a string. |
|||
Write the string on the console without advancing. |
|||
If the entry's next is not nil, write ", " on the console without advancing. |
|||
Put the entry's next into the entry. |
|||
Repeat.</lang> |
|||
{{out}} |
|||
<pre> |
|||
5, 22, 12, 21, 38 |
|||
</pre> |
|||
=={{header|Raku}}== |
=={{header|Raku}}== |