Add tasks for all the new languages

This commit is contained in:
Tina Müller 2016-12-05 23:44:36 +01:00
parent 9dc3c2bb62
commit bba7bfd280
13208 changed files with 134745 additions and 0 deletions

View file

@ -0,0 +1,3 @@
string count = '12345';
count = String.valueOf(integer.valueOf(count)+1);
system.debug('Incremental Value : '+count);

View file

@ -0,0 +1,18 @@
shared void run() {
"Increments a numeric string by 1. Returns a float or integer depending on the string.
Returns null if the string isn't a number."
function inc(String string) =>
if(exists integer = parseInteger(string)) then integer + 1
else if(exists float = parseFloat(string)) then float + 1.0
else null;
value a = "1";
print(a);
value b = inc(a);
print(b);
value c = "1.0";
print(c);
value d = inc(c);
print(d);
}

View file

@ -0,0 +1,4 @@
....................
s$="12345"
s$=STR$(VAL(s$)+1)
....................

View file

@ -0,0 +1,2 @@
(number->string (1+ (string->number "665")))
→ "666"

View file

@ -0,0 +1,9 @@
#import <Foundation/Foundation.h>
int main()
i := (int)'123' + 1
s := @(i).description
Log( '%@', s )
return 0

View file

@ -0,0 +1,15 @@
' FB 1.05.0 Win64
Function Increment (num As String) As String
Dim d As Double = Val(num)
Return Str(d + 1.0)
End Function
Dim num(5) As String = {"1", "5", "81", "123.45", "777.77", "1000"}
For i As Integer = 0 To 5
Print num(i); " + 1", " = "; Increment(num(i))
Next
Print
Print "Press any key to exit"
Sleep

View file

@ -0,0 +1,18 @@
include "ConsoleWindow"
dim as Str255 numStr
dim as long numeric, i
numStr = "12345"
numeric = val(numStr)
numeric++
numStr = str$(numeric)
print numStr
print
for i = 0 to 10
numeric++
numStr = str$( numeric )
print numStr
next

View file

@ -0,0 +1 @@
(integer('123') + 1) -> asstring

View file

@ -0,0 +1,2 @@
put integer("123")+1
-- 124

View file

@ -0,0 +1,4 @@
put "0" & "1234" into myString -- I think this will result in an internal string representation
add 1 to myString -- automatically converts to a number
put "The number is:" && myString
-- outputs "The number is: 1235"

View file

@ -0,0 +1,2 @@
import strutils
let next = $(parseInt("123") + 1)

View file

@ -0,0 +1,2 @@
"999" 1 + println
"999" asInteger 1 + asString println

View file

@ -0,0 +1,2 @@
integer {{n}} = scanf("2047","%d")
printf(1,"%d\n",{n+1})

View file

@ -0,0 +1 @@
x = "1234" See 1+x # print 1235

View file

@ -0,0 +1,2 @@
say '1234'.inc; #=> '1235'
say '99'.inc; #=> '100'

View file

@ -0,0 +1,6 @@
function numStrIncmt(s) {
return fmtstr("%d", toint(s) + 1);
}
spn:1> numStrIncmt("12345")
= 12346

View file

@ -0,0 +1,4 @@
let s = "1234"
if let x = Int(s) {
print("\(x + 1)")
}

View file

@ -0,0 +1,4 @@
let s = "1234"
if let x = s.toInt() {
println("\(x + 1)")
}

View file

@ -0,0 +1,3 @@
decl string num
set num "123"
set num (int (+ (int num) 1))

View file

@ -0,0 +1,2 @@
(DEFUN INCREMENT-STRING (X)
(NUMBER->STRING (+ (STRING->NUMBER X) 1)))

View file

@ -0,0 +1 @@
$ jq -n -M -s 'map(tonumber) | add' input.txt

View file

@ -0,0 +1,18 @@
# This function assumes its string arguments represent non-negative decimal integers.
def long_add(num1; num2):
if (num1|length) < (num2|length) then long_add(num2; num1)
else (num1 | explode | map(.-48) | reverse) as $a1
| (num2 | explode | map(.-48) | reverse) as $a2
| reduce range(0; num1|length) as $ix
($a2; # result
( $a1[$ix] + .[$ix] ) as $r
| if $r > 9 # carrying
then
.[$ix + 1] = ($r / 10 | floor) +
(if $ix + 1 >= length then 0 else .[$ix + 1] end )
| .[$ix] = $r - ( $r / 10 | floor ) * 10
else
.[$ix] = $r
end )
| reverse | map(.+48) | implode
end ;

View file

@ -0,0 +1 @@
long_add("9" * 100; "1")