September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
11
Task/Loops-Foreach/BASIC/loops-foreach-3.basic
Normal file
11
Task/Loops-Foreach/BASIC/loops-foreach-3.basic
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
10 DIM A$(9) :REM DECLARE STRING ARRAY
|
||||
20 REM *** FILL ARRAY WITH WORDS ***
|
||||
30 FOR I = 0 TO 8
|
||||
40 READ A$(I)
|
||||
50 NEXT
|
||||
60 REM *** PRINT ARRAY CONTENTS ***
|
||||
70 FOR I = 0 TO 8
|
||||
80 PRINT A$(I)" ";
|
||||
90 NEXT
|
||||
100 END
|
||||
1000 DATA THE, QUICK, BROWN, FOX, JUMPS, OVER, THE, LAZY, DOG.
|
||||
19
Task/Loops-Foreach/BASIC/loops-foreach-4.basic
Normal file
19
Task/Loops-Foreach/BASIC/loops-foreach-4.basic
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
DEF AnArray[11]:INT
|
||||
|
||||
AnArray=0,1,2,3,4,5,6,7,8,9,10
|
||||
|
||||
'A console only program will work without OPENCONSOLE and
|
||||
'CLOSECONSOLE; however, it does not hurt to use them.
|
||||
OPENCONSOLE
|
||||
|
||||
FOR X=0 TO 10
|
||||
PRINT AnArray[X]
|
||||
NEXT X
|
||||
|
||||
'keep the console from closing right away.
|
||||
DO:UNTIL INKEY$<>""
|
||||
|
||||
CLOSECONSOLE
|
||||
|
||||
'because this is a console only program.
|
||||
END
|
||||
32
Task/Loops-Foreach/BASIC/loops-foreach-6.basic
Normal file
32
Task/Loops-Foreach/BASIC/loops-foreach-6.basic
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
DEF AList:POINTER
|
||||
|
||||
AList=ListCreate()
|
||||
|
||||
'Add items to the list.
|
||||
DEF X:INT
|
||||
|
||||
FOR X=0 TO 10
|
||||
POINTER Temp=ListAdd(AList,NEW(INT,1))
|
||||
#<INT>temp=X
|
||||
'The hash ("#") dereferencing operator is unique to IWBASIC and Creative Basic, and
|
||||
'it is suitable for most basic pointer needs. IWBASIC also supports a "C style"
|
||||
'dereferencing operator: "*". And that will work here too.
|
||||
NEXT X
|
||||
|
||||
'A program compiled as console only does not need the commands to open and
|
||||
'close the console. However, it does not hurt to use them.
|
||||
OPENCONSOLE
|
||||
|
||||
'***Iterate the list with the "for each" loop***
|
||||
FOR Temp=EACH AList AS INT
|
||||
PRINT #Temp
|
||||
NEXT
|
||||
|
||||
PRINT
|
||||
|
||||
'A press any key to continue message is automatic in a program compiled as a console only
|
||||
program. I presume the compiler inserts the code.
|
||||
CLOSECONSOLE
|
||||
|
||||
'Because this is a console only program.
|
||||
END
|
||||
17
Task/Loops-Foreach/BASIC/loops-foreach-7.basic
Normal file
17
Task/Loops-Foreach/BASIC/loops-foreach-7.basic
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
DEF AnArray[11]:INT
|
||||
|
||||
AnArray=0,1,2,3,4,5,6,7,8,9,10
|
||||
|
||||
OPENCONSOLE
|
||||
|
||||
FOR X=0 TO 10
|
||||
PRINT AnArray[X]
|
||||
NEXT X
|
||||
|
||||
PRINT
|
||||
|
||||
'a press any key message is automatic when compiled as console only.
|
||||
CLOSECONSOLE
|
||||
|
||||
'Because this is a console only program.
|
||||
END
|
||||
6
Task/Loops-Foreach/Bc/loops-foreach.bc
Normal file
6
Task/Loops-Foreach/Bc/loops-foreach.bc
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
a[0] = .123
|
||||
a[1] = 234
|
||||
a[3] = 95.6
|
||||
for (i = 0; i < 4; i++) {
|
||||
a[i]
|
||||
}
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
open console imperative
|
||||
|
||||
each writen [1..10]
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
each f (x::xs) = f x $ each f xs
|
||||
each _ [] = ()
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
open console list
|
||||
|
||||
_ = map writen [1..10]
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
each (x::xs) = writen x $ each xs
|
||||
each [] = ()
|
||||
|
||||
each [1..10]
|
||||
|
|
@ -1,10 +1,12 @@
|
|||
#import system.
|
||||
#import system'routines.
|
||||
#import extensions'routines.
|
||||
import system'routines.
|
||||
import extensions.
|
||||
|
||||
#symbol program =
|
||||
program =
|
||||
[
|
||||
#var things := ("Apple", "Banana", "Coconut").
|
||||
var things := ("Apple", "Banana", "Coconut").
|
||||
|
||||
things run &each:printingLn.
|
||||
things forEach(:thing)
|
||||
[
|
||||
console printLine:thing.
|
||||
]
|
||||
].
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
for path in $PATH
|
||||
echo You have $path in PATH.
|
||||
end
|
||||
9
Task/Loops-Foreach/Gambas/loops-foreach.gambas
Normal file
9
Task/Loops-Foreach/Gambas/loops-foreach.gambas
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
Public Sub Main()
|
||||
Dim siInput As Short[] = [1, 8, 0, 6, 4, 7, 3, 2, 5, 9]
|
||||
Dim siTemp As Short
|
||||
|
||||
For Each siTemp In siInput.Sort()
|
||||
Print siTemp;;
|
||||
Next
|
||||
|
||||
End
|
||||
5
Task/Loops-Foreach/Halon/loops-foreach.halon
Normal file
5
Task/Loops-Foreach/Halon/loops-foreach.halon
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
$things = ["Apple", "Banana", "Coconut"];
|
||||
|
||||
foreach ($things as $thing) {
|
||||
echo $thing;
|
||||
}
|
||||
1
Task/Loops-Foreach/Hy/loops-foreach.hy
Normal file
1
Task/Loops-Foreach/Hy/loops-foreach.hy
Normal file
|
|
@ -0,0 +1 @@
|
|||
(for [x collection] (print x))
|
||||
10
Task/Loops-Foreach/Kotlin/loops-foreach.kotlin
Normal file
10
Task/Loops-Foreach/Kotlin/loops-foreach.kotlin
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
// version 1.0.6
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val greek = arrayOf("alpha", "beta", "gamma", "delta")
|
||||
for (letter in greek) print("$letter ")
|
||||
println()
|
||||
// or alternatively
|
||||
greek.forEach { print("$it ") }
|
||||
println()
|
||||
}
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
var list: seq[string] = @[]
|
||||
list.add("lorem")
|
||||
list.add("ipsum")
|
||||
list.add("dolor")
|
||||
for i in items(list):
|
||||
echo(i)
|
||||
13
Task/Loops-Foreach/OoRexx/loops-foreach.rexx
Normal file
13
Task/Loops-Foreach/OoRexx/loops-foreach.rexx
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
/* Rexx */
|
||||
say
|
||||
say 'Loops/Foreach'
|
||||
out = ''
|
||||
|
||||
days = .array~of('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday')
|
||||
|
||||
loop daysi over days
|
||||
out ||= daysi' '
|
||||
end daysi
|
||||
say out~strip()
|
||||
|
||||
exit
|
||||
4
Task/Loops-Foreach/Stata/loops-foreach.stata
Normal file
4
Task/Loops-Foreach/Stata/loops-foreach.stata
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
local a 2 9 4 7 5 3 6 1 8
|
||||
foreach i in `a' {
|
||||
display "`i'"
|
||||
}
|
||||
|
|
@ -1,8 +1,5 @@
|
|||
dim items(2)
|
||||
items(0)="Apple"
|
||||
items(1)="Orange"
|
||||
items(2)="Banana"
|
||||
items = Array("Apple", "Orange", "Banana")
|
||||
|
||||
For Each x in items
|
||||
WScript.Echo x
|
||||
For Each x In items
|
||||
WScript.Echo x
|
||||
Next
|
||||
|
|
|
|||
2
Task/Loops-Foreach/Zkl/loops-foreach-1.zkl
Normal file
2
Task/Loops-Foreach/Zkl/loops-foreach-1.zkl
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
foreach c in (T("Red","Green","Blue","Black","White"))
|
||||
{ print(c," "); }
|
||||
2
Task/Loops-Foreach/Zkl/loops-foreach-2.zkl
Normal file
2
Task/Loops-Foreach/Zkl/loops-foreach-2.zkl
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
foreach x,y,z in (T(T(1,2,3), T(4,5,6))) { println(x,y,z) }
|
||||
foreach x,y,z in (T(1,2,3), T(4,5), T(6)){ println(x,y,z) }
|
||||
Loading…
Add table
Add a link
Reference in a new issue