Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
10
Task/Count-in-octal/FreeBASIC/count-in-octal.freebasic
Normal file
10
Task/Count-in-octal/FreeBASIC/count-in-octal.freebasic
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
' FB 1.05.0 Win64
|
||||
|
||||
Dim ub As UByte = 0 ' only has a range of 0 to 255
|
||||
Do
|
||||
Print Oct(ub, 3)
|
||||
ub += 1
|
||||
Loop Until ub = 0 ' wraps around to 0 when reaches 256
|
||||
Print
|
||||
Print "Press any key to quit"
|
||||
Sleep
|
||||
9
Task/Count-in-octal/Futhark/count-in-octal.futhark
Normal file
9
Task/Count-in-octal/Futhark/count-in-octal.futhark
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
fun octal(x: int): int =
|
||||
loop ((out,mult,x) = (0,1,x)) = while x > 0 do
|
||||
let digit = x % 8
|
||||
let out = out + digit * mult
|
||||
in (out, mult * 10, x / 8)
|
||||
in out
|
||||
|
||||
fun main(n: int): [n]int =
|
||||
map octal (iota n)
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
include "ConsoleWindow
|
||||
defstr word
|
||||
|
||||
dim as short i
|
||||
|
||||
for i = &o000000 to &o000031 // 0 to 25 in decimal
|
||||
print oct$(i); " in octal ="; i
|
||||
next
|
||||
4
Task/Count-in-octal/LFE/count-in-octal.lfe
Normal file
4
Task/Count-in-octal/LFE/count-in-octal.lfe
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
(: lists foreach
|
||||
(lambda (x)
|
||||
(: io format '"~p~n" (list (: erlang integer_to_list x 8))))
|
||||
(: lists seq 0 2000))
|
||||
3
Task/Count-in-octal/Nim/count-in-octal.nim
Normal file
3
Task/Count-in-octal/Nim/count-in-octal.nim
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
import strutils
|
||||
for i in 0 .. <int64.high:
|
||||
echo toOct(i, 16)
|
||||
6
Task/Count-in-octal/Phix/count-in-octal.phix
Normal file
6
Task/Count-in-octal/Phix/count-in-octal.phix
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
integer i = 0
|
||||
constant ESC = #1B
|
||||
while not find(get_key(),{ESC,'q','Q'}) do
|
||||
printf(1,"%o\n",i)
|
||||
i += 1
|
||||
end while
|
||||
14
Task/Count-in-octal/Ring/count-in-octal.ring
Normal file
14
Task/Count-in-octal/Ring/count-in-octal.ring
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
size = 30
|
||||
for n = 1 to size
|
||||
see octal(n) + nl
|
||||
next
|
||||
|
||||
func octal m
|
||||
output = ""
|
||||
w = m
|
||||
while fabs(w) > 0
|
||||
oct = w & 7
|
||||
w = floor(w / 8)
|
||||
output = string(oct) + output
|
||||
end
|
||||
return output
|
||||
2
Task/Count-in-octal/Sidef/count-in-octal.sidef
Normal file
2
Task/Count-in-octal/Sidef/count-in-octal.sidef
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
var i = 0;
|
||||
loop { say i++.as_oct }
|
||||
3
Task/Count-in-octal/Sparkling/count-in-octal.sparkling
Normal file
3
Task/Count-in-octal/Sparkling/count-in-octal.sparkling
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
for (var i = 0; true; i++) {
|
||||
printf("%o\n", i);
|
||||
}
|
||||
28
Task/Count-in-octal/Swift/count-in-octal.swift
Normal file
28
Task/Count-in-octal/Swift/count-in-octal.swift
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
import Foundation
|
||||
|
||||
func octalSuccessor(value: String) -> String {
|
||||
if value.isEmpty {
|
||||
return "1"
|
||||
} else {
|
||||
let i = value.startIndex, j = value.endIndex.predecessor()
|
||||
switch (value[j]) {
|
||||
case "0": return value[i..<j] + "1"
|
||||
case "1": return value[i..<j] + "2"
|
||||
case "2": return value[i..<j] + "3"
|
||||
case "3": return value[i..<j] + "4"
|
||||
case "4": return value[i..<j] + "5"
|
||||
case "5": return value[i..<j] + "6"
|
||||
case "6": return value[i..<j] + "7"
|
||||
case "7": return octalSuccessor(value[i..<j]) + "0"
|
||||
default:
|
||||
NSException(name:"InvalidDigit", reason: "InvalidOctalDigit", userInfo: nil).raise();
|
||||
return ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var n = "0"
|
||||
while strtoul(n, nil, 8) < UInt.max {
|
||||
println(n)
|
||||
n = octalSuccessor(n)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue