Queue/Usage: Difference between revisions
Content added Content deleted
m ({{Template:See also lists}}) |
(→{{header|ALGOL 68}}: use # Stigler's 1939 Diet ... # as test data.) |
||
Line 35: | Line 35: | ||
=={{header|ALGOL 68}}== |
|||
{{works with|ALGOL 68|Revision 1 - one extension to language used - PRAGMA READ - a non standard feature similar to C's #include directive.}} |
|||
{{works with|ALGOL 68G|Any - tested with release [http://sourceforge.net/projects/algol68/files/algol68g/algol68g-2.7 algol68g-2.7].}} |
|||
{{wont work with|ELLA ALGOL 68|Any (with appropriate job cards) - tested with release [http://sourceforge.net/projects/algol68/files/algol68toc/algol68toc-1.8.8d/algol68toc-1.8-8d.fc9.i386.rpm/download 1.8-8d] - due to extensive use of '''format'''[ted] ''transput''.}} |
|||
'''File: test/data_stigler_diet.a68'''<lang algol68># -*- coding: utf-8 -*- # |
|||
MODE DIETITEM = STRUCT( |
|||
STRING food, annual quantity, units, REAL cost |
|||
); |
|||
# Stigler's 1939 Diet ... # |
|||
FORMAT diet item fmt = $g": "g" "g" = $"zzd.dd$; |
|||
[]DIETITEM stigler diet = ( |
|||
("Cabbage", "111","lb.", 4.11), |
|||
("Dried Navy Beans", "285","lb.", 16.80), |
|||
("Evaporated Milk", "57","cans", 3.84), |
|||
("Spinach", "23","lb.", 1.85), |
|||
("Wheat Flour", "370","lb.", 13.33), |
|||
("Total Annual Cost", "","", 39.93) |
|||
)</lang>'''File: test/queue.a68'''<lang algol68>#!/usr/bin/a68g --script # |
|||
# -*- coding: utf-8 -*- # |
|||
MODE QUEUEVALUE = DIETITEM; |
|||
PR read "prelude/queue.a68" PR; |
|||
PR read "test/data_stigler_diet.a68" PR; |
|||
QUEUE example; queue init(example); |
|||
FOR i TO UPB stigler diet DO |
|||
queue put(example, stigler diet[i]) |
|||
OD; |
|||
printf($"Item queue:"l$); |
|||
WHILE NOT queue is empty(example) DO |
|||
# OR example ISNT queue empty # |
|||
printf((diet item fmt, queue get(example), $l$)) |
|||
OD</lang>'''Output:''' |
|||
<pre> |
|||
Item queue: |
|||
Cabbage: 111 lb. = $ 4.11 |
|||
Dried Navy Beans: 285 lb. = $ 16.80 |
|||
Evaporated Milk: 57 cans = $ 3.84 |
|||
Spinach: 23 lb. = $ 1.85 |
|||
Wheat Flour: 370 lb. = $ 13.33 |
|||
Total Annual Cost: = $ 39.93 |
|||
</pre> |
|||
=={{header|AppleScript}}== |
=={{header|AppleScript}}== |
||
<lang AppleScript >on push(StackRef, value) |
<lang AppleScript >on push(StackRef, value) |