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,13 @@
' FB 1.05.0 Win64
Dim x(0 To 3) As Double = {1, 2, 3, 1e11}
Dim y(0 To 3) As Double = {1, 1.4142135623730951, 1.7320508075688772, 316227.76601683791}
Open "output.txt" For Output As #1
For i As Integer = 0 To 2
Print #1, Using "#"; x(i);
Print #1, Spc(7); Using "#.####"; y(i)
Next
Print #1, Using "#^^^^"; x(3);
Print #1, Spc(2); Using "##.####^^^^"; y(3)
Close #1

View file

@ -0,0 +1,15 @@
on saveFloatLists (filename, x, y, xprecision, yprecision)
eol = numtochar(10) -- LF
fp = xtra("fileIO").new()
fp.openFile(tFile, 2)
cnt = x.count
repeat with i = 1 to cnt
the floatPrecision = xprecision
fp.writeString(string(x[i])
fp.writeString(TAB)
the floatPrecision = yprecision
fp.writeString(string(y[i])
fp.writeString(eol)
end repeat
fp.closeFile()
end

View file

@ -0,0 +1,3 @@
x = [1.0, PI, sqrt(2)]
y = [2.0, log(10), sqrt(3)]
saveFloatLists("floats.txt", x, y, 3, 5)

View file

@ -0,0 +1,21 @@
import strutils, math, sequtils
const
outFileName = "floatarr2file.txt"
proc sqrt*(x: int64): float {.importc: "sqrt", header: "<math.h>".}
const
xprecision = 3
yprecision = 5
var a: seq[int64] = @[int64(1), 2, 3, 100_000_000_000]
var b: seq[float] = @[sqrt(a[0]), sqrt(a[1]), sqrt(a[2]), sqrt(a[3])]
var c = zip(a,b)
var res: string = ""
for t in c:
res.add($formatFloat(float(t.a),ffDefault,xprecision) & "\t" & $formatFloat(t.b,ffDefault,yprecision) & "\n")
writeFile(outFileName,res)
var res2 = readFile(outFileName)
echo(res2)

View file

@ -0,0 +1,8 @@
constant x = {1, 2, 3, 1e11},
y = {1, 1.4142135623730951, 1.7320508075688772, 316227.76601683791}
integer fn = open("filename","w")
for i=1 to length(x) do
printf(fn,"%.3g\t%.5g\n",{x[i],y[i]})
end for
close(fn)

View file

@ -0,0 +1,14 @@
func writedat(filename, x, y, x_precision=3, y_precision=5) {
var fh = File.new(filename).open_w;
MultiArray.new(x, y).each { |x, y|
fh.printf("%.*g\t%.*g\n", x_precision, x, y_precision, y);
}
fh.close;
}
var x = [1, 2, 3, 1e11];
var y = x»sqrt»();
writedat('sqrt.dat', x, y);

View file

@ -0,0 +1,4 @@
[1, 2, 3, 1e11] as $x
| $x | map(sqrt) as $y
| range(0; $x|length) as $i
| "\($x[$i]) \($y[$i])"

View file

@ -0,0 +1 @@
$ jq -n -r -f Write_float_arrays_to_a_text_file.jq > filename