Nested function: Difference between revisions
Content added Content deleted
(Added Algol W) |
|||
Line 67: | Line 67: | ||
print( ( make list( ". " ) ) ) |
print( ( make list( ". " ) ) ) |
||
</lang> |
</lang> |
||
=={{header|ALGOL W}}== |
|||
Algol W strings are fixed length which makes this slightly more complicated than the Algol 68 solution. |
|||
<lang algolw>begin |
|||
string(30) procedure makeList ( string(2) value separator ) ; |
|||
begin |
|||
string(30) listValue; |
|||
integer counter; |
|||
string(10) procedure makeItem ( string(6) value item |
|||
; integer value length |
|||
) ; |
|||
begin |
|||
string(10) listItem; |
|||
counter := counter + 1; |
|||
listItem( 0 // 1 ) := code( decode( "0" ) + counter ); |
|||
listItem( 1 // 2 ) := separator; |
|||
listItem( 3 // 6 ) := item; |
|||
listItem( 3 + length // 1 ) := code( 10 ); |
|||
listItem |
|||
end; % makeItem % |
|||
counter := 0; |
|||
listValue := makeItem( "first", 5 ); |
|||
listValue( 9 // 10 ) := makeItem( "second", 6 ); |
|||
listValue( 19 // 10 ) := makeItem( "third", 5 ); |
|||
listValue |
|||
end; % makeList % |
|||
write( makeList( ". " ) ) |
|||
end.</lang> |
|||
=={{header|AppleScript}}== |
=={{header|AppleScript}}== |