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,2 @@
7.125 "%09.3f" s:strfmt
. cr

View file

@ -0,0 +1,41 @@
PROGRAM FORMATTED
PROCEDURE FORMATTED_PRINT(N,LENGTH,DEC_PLACES->FP$)
LOCAL I,C$,NN$
FORMAT$=STRING$(LENGTH,"#")+"."
FOR I=1 TO DEC_PLACES DO
FORMAT$=FORMAT$+"#"
END FOR
OPEN("O",1,"FORMAT.$$$")
WRITE(#1,FORMAT$;N)
CLOSE(1)
OPEN("I",1,"FORMAT.$$$")
INPUT(LINE,#1,N$)
CLOSE(1)
! add leading zeros
FOR I=1 TO LEN(N$) DO
C$=MID$(N$,I,1)
IF C$=" " OR C$="%" THEN NN$=NN$+"0" ELSE NN$=NN$+C$
END FOR
FP$=RIGHT$("000000000000"+NN$,LENGTH) ! chop to required length
END PROCEDURE
BEGIN
PRINT(CHR$(12);) ! CLS
FOR I=1 TO 10 DO
N=RND(1)*10^(INT(10*RND(1))-2)
FORMATTED_PRINT(N,16,5->FP$)
PRINT("Raw number =";N;TAB(30);"Using custom function =";FP$)
END FOR
END PROGRAM

View file

@ -0,0 +1,7 @@
' FB 1.05.0 Win64
#Include "vbcompat.bi"
Dim s As String = Format(7.125, "00000.0##")
Print s
Sleep

View file

@ -0,0 +1,3 @@
include "ConsoleWindow"
print using "0000#.###"; 7.125

View file

@ -0,0 +1 @@
7.125 -> asstring(-precision = 3, -padding = 9, -padchar = '0')

View file

@ -0,0 +1,7 @@
import strfmt
const r = 7.125
echo r
echo((-r).format("9.3f"))
echo(r.format("9.3f"))
echo((-r).format("09.3f"))
echo(r.format("09.3f"))

View file

@ -0,0 +1 @@
printf(1,"%09.3f\n",7.125)

View file

@ -0,0 +1,8 @@
decimals(3)
see fixedprint(7.125, 5) + nl
func fixedprint num, digs
for i = 1 to digs - len(string(floor(num)))
see "0"
next
see num + nl

View file

@ -0,0 +1 @@
printf("%09.3f\n", 7.125);

View file

@ -0,0 +1 @@
say ("%09.3f" % 7.125);

View file

@ -0,0 +1,15 @@
def pp0(width):
tostring
| if width > length then (width - length) * "0" + . else . end;
# pp(left; right) formats a decimal number to occupy
# (left+right+1) positions if possible,
# where "left" is the number of characters to the left of
# the decimal point, and similarly for "right".
def pp(left; right):
def lpad: if (left > length) then ((left - length) * "0") + . else . end;
tostring as $s
| $s
| index(".") as $ix
| ((if $ix then $s[0:$ix] else $s end) | lpad) + "." +
(if $ix then $s[$ix+1:] | .[0:right] else "" end);

View file

@ -0,0 +1 @@
(1.0, 12.3, 333.333, 1e6) | pp0(10)

View file

@ -0,0 +1,4 @@
0000000001
00000012.3
000333.333
0001000000

View file

@ -0,0 +1 @@
(1.0, 12.3, 333.333, 1e6) | pp(4;2)

View file

@ -0,0 +1,4 @@
0001.
0012.3
0333.33
1000000.