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,3 @@
|
|||
string count = '12345';
|
||||
count = String.valueOf(integer.valueOf(count)+1);
|
||||
system.debug('Incremental Value : '+count);
|
||||
|
|
@ -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);
|
||||
}
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
....................
|
||||
s$="12345"
|
||||
s$=STR$(VAL(s$)+1)
|
||||
....................
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
(number->string (1+ (string->number "665")))
|
||||
→ "666"
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
#import <Foundation/Foundation.h>
|
||||
|
||||
int main()
|
||||
|
||||
i := (int)'123' + 1
|
||||
s := @(i).description
|
||||
|
||||
Log( '%@', s )
|
||||
return 0
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -0,0 +1 @@
|
|||
(integer('123') + 1) -> asstring
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
put integer("123")+1
|
||||
-- 124
|
||||
|
|
@ -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"
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
import strutils
|
||||
let next = $(parseInt("123") + 1)
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
"999" 1 + println
|
||||
"999" asInteger 1 + asString println
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
integer {{n}} = scanf("2047","%d")
|
||||
printf(1,"%d\n",{n+1})
|
||||
|
|
@ -0,0 +1 @@
|
|||
x = "1234" See 1+x # print 1235
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
say '1234'.inc; #=> '1235'
|
||||
say '99'.inc; #=> '100'
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
function numStrIncmt(s) {
|
||||
return fmtstr("%d", toint(s) + 1);
|
||||
}
|
||||
|
||||
spn:1> numStrIncmt("12345")
|
||||
= 12346
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
let s = "1234"
|
||||
if let x = Int(s) {
|
||||
print("\(x + 1)")
|
||||
}
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
let s = "1234"
|
||||
if let x = s.toInt() {
|
||||
println("\(x + 1)")
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
decl string num
|
||||
set num "123"
|
||||
set num (int (+ (int num) 1))
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
(DEFUN INCREMENT-STRING (X)
|
||||
(NUMBER->STRING (+ (STRING->NUMBER X) 1)))
|
||||
|
|
@ -0,0 +1 @@
|
|||
$ jq -n -M -s 'map(tonumber) | add' input.txt
|
||||
|
|
@ -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 ;
|
||||
|
|
@ -0,0 +1 @@
|
|||
long_add("9" * 100; "1")
|
||||
Loading…
Add table
Add a link
Reference in a new issue