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
|
|
@ -0,0 +1,17 @@
|
|||
compare:
|
||||
push psw
|
||||
cjne a, b, clt
|
||||
; a == b
|
||||
; implement code here
|
||||
jmp compare_
|
||||
clt:
|
||||
jc lt
|
||||
; a > b
|
||||
; implement code here
|
||||
jmp compare_
|
||||
lt:
|
||||
; a < b
|
||||
; implement code here
|
||||
compare_:
|
||||
pop psw
|
||||
ret
|
||||
4
Task/Integer-comparison/8th/integer-comparison.8th
Normal file
4
Task/Integer-comparison/8th/integer-comparison.8th
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
: compare \ n m --
|
||||
2dup n:= if "They are equal" . cr then
|
||||
2dup n:< if "First less than second" . cr then
|
||||
n:> if "First greater than second" . cr then ;
|
||||
11
Task/Integer-comparison/Axe/integer-comparison.axe
Normal file
11
Task/Integer-comparison/Axe/integer-comparison.axe
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
Lbl FUNC
|
||||
If r₁<r₂
|
||||
Disp "LESS THAN",i
|
||||
End
|
||||
If r₁=r₂
|
||||
Disp "EQUAL TO",i
|
||||
End
|
||||
If r₁>r₂
|
||||
Disp "GREATER THAN",i
|
||||
End
|
||||
Return
|
||||
8
Task/Integer-comparison/ChucK/integer-comparison.chuck
Normal file
8
Task/Integer-comparison/ChucK/integer-comparison.chuck
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
fun void intComparison (int one, int two)
|
||||
{
|
||||
if(one < two) <<< one, " is less than ", two >>>;
|
||||
if(one == two) <<< one, " is equal than ", two >>>;
|
||||
if(one > two) <<< one, " is greater than ", two >>>;
|
||||
}
|
||||
// uncomment next line and change values to test
|
||||
// intComparison (2,4);
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
start: STP ; get input
|
||||
|
||||
x: NOP
|
||||
y: NOP
|
||||
|
||||
LDA x
|
||||
SUB y
|
||||
BRZ start ; x=y, A=0
|
||||
|
||||
loop: LDA x
|
||||
SUB one
|
||||
BRZ x<y
|
||||
STA x
|
||||
|
||||
LDA y
|
||||
SUB one
|
||||
BRZ x>y
|
||||
STA y
|
||||
|
||||
JMP loop
|
||||
|
||||
x>y: LDA one ; A := 1
|
||||
JMP start
|
||||
|
||||
x<y: SUB one ; A := 0-1
|
||||
JMP start
|
||||
|
||||
one: 1
|
||||
9
Task/Integer-comparison/ECL/integer-comparison.ecl
Normal file
9
Task/Integer-comparison/ECL/integer-comparison.ecl
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
CompareThem(INTEGER A,INTEGER B) := FUNCTION
|
||||
Result := A <=> B;
|
||||
STRING ResultText := CASE (Result,1 => 'is greater than', 0 => 'is equal to','is less than');
|
||||
RETURN A + ' ' + TRIM(ResultText) + ' ' + B;
|
||||
END;
|
||||
|
||||
CompareThem(1,2); //Shows "1 is less than 2"
|
||||
CompareThem(2,2); //Shows "2 is equal to 2"
|
||||
CompareThem(2,1); //Shows "2 is greater than 1"
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
[ Integer comparison
|
||||
==================
|
||||
|
||||
A program for the EDSAC
|
||||
|
||||
Illustrates the use of the E
|
||||
(branch on accumulator sign
|
||||
bit clear) and G (branch on
|
||||
accumulator sign bit set)
|
||||
orders
|
||||
|
||||
The integers to be tested, x
|
||||
and y, should be stored in
|
||||
addresses 13@ and 14@
|
||||
|
||||
Output: the program causes the
|
||||
machine to print
|
||||
'+' if x > y,
|
||||
'=' if x = y,
|
||||
'-' if x < y.
|
||||
|
||||
Works with Initial Orders 2 ]
|
||||
|
||||
T56K [ load point ]
|
||||
GK [ base address ]
|
||||
|
||||
O15@ [ figure shift ]
|
||||
|
||||
A13@ [ a = x ]
|
||||
S14@ [ a -= y ]
|
||||
G10@ [ if a<0 go to 10 ]
|
||||
|
||||
S12@ [ a -= 1 ]
|
||||
E8@ [ if a>=0 go to 8 ]
|
||||
|
||||
O17@ [ write '=' ]
|
||||
ZF [ halt ]
|
||||
|
||||
[ 8 ] O16@ [ write '+' ]
|
||||
ZF [ halt ]
|
||||
|
||||
[ 10 ] O18@ [ write '-' ]
|
||||
ZF [ halt ]
|
||||
|
||||
[ 12 ] P0D [ const: 1 ]
|
||||
|
||||
[ 13 ] P16D [ x = 37 ]
|
||||
[ 14 ] P14F [ y = 28 ]
|
||||
|
||||
[ 15 ] #F [ figure shift ]
|
||||
[ 16 ] ZF [ + character ]
|
||||
[ 17 ] VF [ = character ]
|
||||
[ 18 ] AF [ - character ]
|
||||
|
||||
EZPF [ begin execution ]
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
' FB 1.05.0 Win64
|
||||
|
||||
Dim As Integer x, y
|
||||
Input "Please enter two integers, separated by a comma : ", x , y
|
||||
|
||||
If x < y Then
|
||||
Print x; " is less than "; y
|
||||
End If
|
||||
|
||||
If x = y Then
|
||||
Print x; " is equal to "; y
|
||||
End If
|
||||
|
||||
If x > y Then
|
||||
Print x; " is greater than "; y
|
||||
End If
|
||||
|
||||
Print
|
||||
Print "Press any key to exit"
|
||||
Sleep
|
||||
8
Task/Integer-comparison/FunL/integer-comparison.funl
Normal file
8
Task/Integer-comparison/FunL/integer-comparison.funl
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
import console.readInt
|
||||
|
||||
a = readInt()
|
||||
b = readInt()
|
||||
|
||||
val (_, c) = [((<), 'less than'), ((==), 'equal to'), ((>), 'greater than')].find( (compare, _) -> compare(a, b) ).get()
|
||||
|
||||
println( "$a is $c $b." )
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
include "ConsoleWindow"
|
||||
|
||||
dim as long n1, n2
|
||||
|
||||
input "Enter two numbers (separated by a comma) to compare: "; n1, n2
|
||||
|
||||
if n1 < n2 then print : print n1; " is less than"; n2
|
||||
if n1 > n2 then print : print n1; " is greater than"; n2
|
||||
if n1 == n2 then print : print n1; " equals"; n2
|
||||
11
Task/Integer-comparison/Harbour/integer-comparison.harbour
Normal file
11
Task/Integer-comparison/Harbour/integer-comparison.harbour
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
PROCEDURE Compare( a, b )
|
||||
|
||||
IF a < b
|
||||
? "A is less than B"
|
||||
ELSEIF a > b
|
||||
? "A is more than B"
|
||||
ELSE
|
||||
? "A equals B"
|
||||
ENDIF
|
||||
|
||||
RETURN
|
||||
10
Task/Integer-comparison/Lasso/integer-comparison.lasso
Normal file
10
Task/Integer-comparison/Lasso/integer-comparison.lasso
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
local(
|
||||
number1 = integer(web_request -> param('number1')),
|
||||
number2 = integer(web_request -> param('number2'))
|
||||
)
|
||||
|
||||
#number1 < #number2 ? 'Number 1 is less than Number 2' | 'Number 1 is not less than Number 2'
|
||||
'<br />'
|
||||
#number1 == #number2 ? 'Number 1 is the same as Number 2' | 'Number 1 is not the same as Number 2'
|
||||
'<br />'
|
||||
#number1 > #number2 ? 'Number 1 is greater than Number 2' | 'Number 1 is not greater than Number 2'
|
||||
5
Task/Integer-comparison/Lingo/integer-comparison.lingo
Normal file
5
Task/Integer-comparison/Lingo/integer-comparison.lingo
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
on compare (a, b)
|
||||
if a < b then put a&" is less than "&b
|
||||
if a = b then put a&" is equal to "&b
|
||||
if a > b then put a&" is greater than "&b
|
||||
end
|
||||
20
Task/Integer-comparison/LiveCode/integer-comparison.livecode
Normal file
20
Task/Integer-comparison/LiveCode/integer-comparison.livecode
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
ask question "Enter 2 numbers (comma separated)" with empty titled "Enter 2 numbers"
|
||||
if it is not empty then
|
||||
put item 1 of it into num1
|
||||
put item 2 of it into num2
|
||||
if isnumber(num1) and isnumber(num2) then
|
||||
if num1 < num2 then answer num1 && "is less than" && num2
|
||||
if num1 is num2 then answer num1 && "is equal to" && num2
|
||||
if num1 > num2 then answer num1 && "is greater than" && num2
|
||||
|
||||
-- alternative is to use switch case construct
|
||||
switch
|
||||
case (num1 < num2)
|
||||
answer num1 && "is less! than" && num2; break
|
||||
case (num1 > num2)
|
||||
answer num1 && "is greater! than" && num2; break
|
||||
case (num1 = num2)
|
||||
answer num1 && "equal! to" && num2
|
||||
end switch
|
||||
end if
|
||||
end if
|
||||
10
Task/Integer-comparison/Nim/integer-comparison.nim
Normal file
10
Task/Integer-comparison/Nim/integer-comparison.nim
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
import rdstdin, strutils
|
||||
var a = parseInt(readLineFromStdin "Enter value of a: ")
|
||||
var b = parseInt(readLineFromStdin "Enter value of b: ")
|
||||
|
||||
if a < b:
|
||||
echo "a is less than b"
|
||||
elif a > b:
|
||||
echo "a is greater than b"
|
||||
elif a == b:
|
||||
echo "a is equal to b"
|
||||
10
Task/Integer-comparison/Oforth/integer-comparison.oforth
Normal file
10
Task/Integer-comparison/Oforth/integer-comparison.oforth
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
import: console
|
||||
|
||||
: cmpInt
|
||||
| a b |
|
||||
doWhile: [ System.Console askln asInteger dup ->a isNull ]
|
||||
doWhile: [ System.Console askln asInteger dup ->b isNull ]
|
||||
|
||||
a b < ifTrue: [ System.Out a << " is less than " << b << cr ]
|
||||
a b == ifTrue: [ System.Out a << " is equal to " << b << cr ]
|
||||
a b > ifTrue: [ System.Out a << " is greater than " << b << cr ] ;
|
||||
21
Task/Integer-comparison/PHL/integer-comparison.phl
Normal file
21
Task/Integer-comparison/PHL/integer-comparison.phl
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
module intergertest;
|
||||
|
||||
extern printf;
|
||||
extern scanf;
|
||||
|
||||
@Integer main [
|
||||
var a = 0;
|
||||
var b = 0;
|
||||
scanf("%i %i", ref (a), ref (b));
|
||||
|
||||
if (a < b)
|
||||
printf("%i is less than %i\n", a::get, b::get);
|
||||
|
||||
if (a == b)
|
||||
printf("%i is equal to %i\n", a::get, b::get);
|
||||
|
||||
if (a > b)
|
||||
printf("%i is greater than %i\n", a::get, b::get);
|
||||
|
||||
return 0;
|
||||
]
|
||||
12
Task/Integer-comparison/Phix/integer-comparison.phix
Normal file
12
Task/Integer-comparison/Phix/integer-comparison.phix
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
atom a = prompt_number("first number:",{}),
|
||||
b = prompt_number("second number:",{})
|
||||
|
||||
printf(1,"%g is ",a)
|
||||
if a < b then
|
||||
puts(1,"less than")
|
||||
elsif a = b then
|
||||
puts(1,"equal to")
|
||||
elsif a > b then
|
||||
puts(1,"greater than")
|
||||
end if
|
||||
printf(1," %g",b)
|
||||
8
Task/Integer-comparison/Ring/integer-comparison.ring
Normal file
8
Task/Integer-comparison/Ring/integer-comparison.ring
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
Func Compare a,b
|
||||
if a < b
|
||||
See "A is less than B"
|
||||
but a > b
|
||||
See "A is more than B"
|
||||
else
|
||||
See "A equals B"
|
||||
ok
|
||||
21
Task/Integer-comparison/SSEM/integer-comparison.ssem
Normal file
21
Task/Integer-comparison/SSEM/integer-comparison.ssem
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
10101000000000100000000000000000 0. -21 to c
|
||||
10101000000001100000000000000000 1. c to 21
|
||||
10101000000000100000000000000000 2. -21 to c
|
||||
01101000000000010000000000000000 3. Sub. 22
|
||||
00000000000000110000000000000000 4. Test
|
||||
00001000000001000000000000000000 5. Add 16 to CI
|
||||
00101000000000000000000000000000 6. 20 to CI
|
||||
00001000000000010000000000000000 7. Sub. 16
|
||||
00000000000000110000000000000000 8. Test
|
||||
11001000000000000000000000000000 9. 19 to CI
|
||||
10001000000000100000000000000000 10. -17 to c
|
||||
00000000000001110000000000000000 11. Stop
|
||||
01001000000000100000000000000000 12. -18 to c
|
||||
00000000000001110000000000000000 13. Stop
|
||||
00001000000000100000000000000000 14. -16 to c
|
||||
00000000000001110000000000000000 15. Stop
|
||||
10000000000000000000000000000000 16. 1
|
||||
00000000000000000000000000000000 17. 0
|
||||
11111111111111111111111111111111 18. -1
|
||||
11010000000000000000000000000000 19. 11
|
||||
10110000000000000000000000000000 20. 13
|
||||
12
Task/Integer-comparison/Sidef/integer-comparison.sidef
Normal file
12
Task/Integer-comparison/Sidef/integer-comparison.sidef
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
var a = read("a: ", Number);
|
||||
var b = read("b: ", Number);
|
||||
|
||||
if (a < b) {
|
||||
say 'Lower';
|
||||
}
|
||||
elsif (a == b) {
|
||||
say 'Equal';
|
||||
}
|
||||
elsif (a > b) {
|
||||
say 'Greater';
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
let a = 13, b = 37;
|
||||
if a < b {
|
||||
print("a < b");
|
||||
} else if a > b {
|
||||
print("a > b");
|
||||
} else if a == b {
|
||||
print("a == b");
|
||||
} else {
|
||||
print("either a or b or both are NaN");
|
||||
}
|
||||
17
Task/Integer-comparison/Swift/integer-comparison.swift
Normal file
17
Task/Integer-comparison/Swift/integer-comparison.swift
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
import Cocoa
|
||||
|
||||
var input = NSFileHandle.fileHandleWithStandardInput()
|
||||
|
||||
println("Enter two integers separated by a space: ")
|
||||
|
||||
let data = input.availableData
|
||||
let stringArray = NSString(data: data, encoding: NSUTF8StringEncoding)?.componentsSeparatedByString(" ")
|
||||
var a:Int!
|
||||
var b:Int!
|
||||
if (stringArray?.count == 2) {
|
||||
a = stringArray![0].integerValue
|
||||
b = stringArray![1].integerValue
|
||||
}
|
||||
if (a==b) {println("\(a) equals \(b)")}
|
||||
if (a < b) {println("\(a) is less than \(b)")}
|
||||
if (a > b) {println("\(a) is greater than \(b)")}
|
||||
15
Task/Integer-comparison/Ursa/integer-comparison.ursa
Normal file
15
Task/Integer-comparison/Ursa/integer-comparison.ursa
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
decl int first second
|
||||
out "enter first integer: " console
|
||||
set first (in int console)
|
||||
out "enter second integer: " console
|
||||
set second (in int console)
|
||||
|
||||
if (= first second)
|
||||
out "the two integers are equal" endl console
|
||||
end if
|
||||
if (< first second)
|
||||
out first " is less than " second endl console
|
||||
end if
|
||||
if (> first second)
|
||||
out first " is greater than " second endl console
|
||||
end if
|
||||
8
Task/Integer-comparison/Wart/integer-comparison.wart
Normal file
8
Task/Integer-comparison/Wart/integer-comparison.wart
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
a <- (read)
|
||||
a <- (read)
|
||||
prn (if (a < b)
|
||||
: "a is less than b"
|
||||
(a > b)
|
||||
: "a is greater than b"
|
||||
:else
|
||||
: "a equals b")
|
||||
10
Task/Integer-comparison/XLISP/integer-comparison.xlisp
Normal file
10
Task/Integer-comparison/XLISP/integer-comparison.xlisp
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
(DEFUN COMPARE-INTEGERS ()
|
||||
(DISPLAY "Enter two integers separated by a space.")
|
||||
(NEWLINE)
|
||||
(DISPLAY "> ")
|
||||
(DEFINE A (READ))
|
||||
(DEFINE B (READ))
|
||||
(COND
|
||||
((> A B) (DISPLAY "The first number is larger."))
|
||||
((= A B) (DISPLAY "They are equal."))
|
||||
((< A B) (DISPLAY "The first number is smaller."))))
|
||||
16
Task/Integer-comparison/jq/integer-comparison-1.jq
Normal file
16
Task/Integer-comparison/jq/integer-comparison-1.jq
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
# compare/0 compares the first two items if they are numbers,
|
||||
# otherwise an "uncomparable" message is emitted.
|
||||
|
||||
def compare:
|
||||
def english:
|
||||
if .[0] < .[1] then "less than"
|
||||
elif .[0] == .[1] then "equal to"
|
||||
else "greater than"
|
||||
end;
|
||||
if (.[0]|type) == "number" and (.[1]|type) == "number" then
|
||||
"\(.[0]) is \(english) \(.[1])"
|
||||
else
|
||||
"\(.[0]) is uncomparable to \(.[1])"
|
||||
end ;
|
||||
|
||||
compare
|
||||
7
Task/Integer-comparison/jq/integer-comparison-2.jq
Normal file
7
Task/Integer-comparison/jq/integer-comparison-2.jq
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
$ jq -s -r -f Integer_comparison.jq
|
||||
1 2
|
||||
1 is less than 2
|
||||
|
||||
$ jq -s -r -f Integer_comparison.jq
|
||||
1 "a"
|
||||
1 is uncomparable to a
|
||||
Loading…
Add table
Add a link
Reference in a new issue