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
22
Task/File-input-output/FreeBASIC/file-input-output.freebasic
Normal file
22
Task/File-input-output/FreeBASIC/file-input-output.freebasic
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
' FB 1.05.0 Win64
|
||||
|
||||
/'
|
||||
input.txt contains:
|
||||
|
||||
The quick brown fox jumps over the lazy dog.
|
||||
Empty vessels make most noise.
|
||||
Too many chefs spoil the broth.
|
||||
A rolling stone gathers no moss.
|
||||
'/
|
||||
|
||||
Open "output.txt" For Output As #1
|
||||
Open "input.txt" For Input As #2
|
||||
Dim line_ As String ' note that line is a keyword
|
||||
|
||||
While Not Eof(2)
|
||||
Line Input #2, line_
|
||||
Print #1, line_
|
||||
Wend
|
||||
|
||||
Close #2
|
||||
Close #1
|
||||
13
Task/File-input-output/I/file-input-output.i
Normal file
13
Task/File-input-output/I/file-input-output.i
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
software {
|
||||
var data = ""
|
||||
var file = open("input.txt")
|
||||
loop {
|
||||
! data += file(256)
|
||||
issues {
|
||||
break
|
||||
}
|
||||
}
|
||||
delete("output.txt")
|
||||
file = open("output.txt")
|
||||
file(data)
|
||||
}
|
||||
34
Task/File-input-output/Lingo/file-input-output-1.lingo
Normal file
34
Task/File-input-output/Lingo/file-input-output-1.lingo
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
----------------------------------------
|
||||
-- Returns file as ByteArray
|
||||
-- @param {string} tFile
|
||||
-- @return {byteArray|false}
|
||||
----------------------------------------
|
||||
on getBytes (tFile)
|
||||
fp = xtra("fileIO").new()
|
||||
fp.openFile(tFile, 1)
|
||||
if fp.status() then return false
|
||||
data = fp.readByteArray(fp.getLength())
|
||||
fp.closeFile()
|
||||
return data
|
||||
end
|
||||
|
||||
----------------------------------------
|
||||
-- Saves ByteArray to file
|
||||
-- @param {string} tFile
|
||||
-- @param {byteArray} tString
|
||||
-- @return {bool} success
|
||||
----------------------------------------
|
||||
on putBytes (tFile, tByteArray)
|
||||
fp = xtra("fileIO").new()
|
||||
fp.openFile(tFile, 2)
|
||||
err = fp.status()
|
||||
if not (err) then fp.delete()
|
||||
else if (err and not (err = -37)) then return false
|
||||
fp.createFile(tFile)
|
||||
if fp.status() then return false
|
||||
fp.openFile(tFile, 2)
|
||||
if fp.status() then return false
|
||||
fp.writeByteArray(tByteArray)
|
||||
fp.closeFile()
|
||||
return true
|
||||
end
|
||||
2
Task/File-input-output/Lingo/file-input-output-2.lingo
Normal file
2
Task/File-input-output/Lingo/file-input-output-2.lingo
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
data = getBytes("input.txt")
|
||||
putBytes("output.txt", data)
|
||||
2
Task/File-input-output/Nim/file-input-output-1.nim
Normal file
2
Task/File-input-output/Nim/file-input-output-1.nim
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
import os
|
||||
copyfile("input.txt", "output.txt")
|
||||
2
Task/File-input-output/Nim/file-input-output-2.nim
Normal file
2
Task/File-input-output/Nim/file-input-output-2.nim
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
let x = readFile("input.txt")
|
||||
writeFile("output.txt", x)
|
||||
9
Task/File-input-output/Nim/file-input-output-3.nim
Normal file
9
Task/File-input-output/Nim/file-input-output-3.nim
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
var
|
||||
i = open("input.txt")
|
||||
o = open("output.txt", fmWrite)
|
||||
|
||||
for line in i.lines:
|
||||
o.writeln(line)
|
||||
|
||||
i.close()
|
||||
o.close()
|
||||
12
Task/File-input-output/Nim/file-input-output-4.nim
Normal file
12
Task/File-input-output/Nim/file-input-output-4.nim
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
const size = 4096
|
||||
|
||||
var
|
||||
i = open("input.txt")
|
||||
o = open("output.txt", fmWrite)
|
||||
buf: array[size, char]
|
||||
|
||||
while i.readBuffer(buf.addr, size) > 0:
|
||||
discard o.writeBuffer(buf.addr, size)
|
||||
|
||||
i.close()
|
||||
o.close()
|
||||
11
Task/File-input-output/Nim/file-input-output-5.nim
Normal file
11
Task/File-input-output/Nim/file-input-output-5.nim
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
import memfiles
|
||||
|
||||
var
|
||||
i = memfiles.open("input.txt")
|
||||
o = system.open("output.txt", fmWrite)
|
||||
|
||||
var written = o.writeBuffer(i.mem, i.size)
|
||||
assert(written == i.size)
|
||||
|
||||
i.close()
|
||||
o.close()
|
||||
7
Task/File-input-output/Oforth/file-input-output-1.oforth
Normal file
7
Task/File-input-output/Oforth/file-input-output-1.oforth
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
: fcopy(in, out)
|
||||
| f g |
|
||||
File newMode(in, File.BINARY) dup open(File.READ) ->f
|
||||
File newMode(out, File.BINARY) dup open(File.WRITE) ->g
|
||||
|
||||
while(f >> dup notNull) [ g addChar ] drop
|
||||
f close g close ;
|
||||
1
Task/File-input-output/Oforth/file-input-output-2.oforth
Normal file
1
Task/File-input-output/Oforth/file-input-output-2.oforth
Normal file
|
|
@ -0,0 +1 @@
|
|||
fcopy("input.txt", "output.txt")
|
||||
6
Task/File-input-output/Phix/file-input-output-1.phix
Normal file
6
Task/File-input-output/Phix/file-input-output-1.phix
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
integer fn = open("input.txt","rb")
|
||||
string txt = get_text(fn)
|
||||
close(fn)
|
||||
fn = open("output.txt","wb")
|
||||
puts(fn,txt)
|
||||
close(fn)
|
||||
10
Task/File-input-output/Phix/file-input-output-2.phix
Normal file
10
Task/File-input-output/Phix/file-input-output-2.phix
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
integer infn = open("input.txt","r"),
|
||||
outfn = open("output.txt","w")
|
||||
object line
|
||||
while 1 do
|
||||
line = gets(infn)
|
||||
if atom(line) then exit end if
|
||||
puts(outfn,line)
|
||||
end while
|
||||
close(infn)
|
||||
close(outfn)
|
||||
10
Task/File-input-output/Phix/file-input-output-3.phix
Normal file
10
Task/File-input-output/Phix/file-input-output-3.phix
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
integer byte,
|
||||
infd = open("input.txt","rb"),
|
||||
outfd = open("output.txt","wb")
|
||||
while 1 do
|
||||
byte = getc(infd)
|
||||
if byte=-1 then exit end if
|
||||
puts(outfd,byte)
|
||||
end while
|
||||
close(infd)
|
||||
close(outfd)
|
||||
19
Task/File-input-output/Ring/file-input-output.ring
Normal file
19
Task/File-input-output/Ring/file-input-output.ring
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
fn1 = "ReadMe.txt"
|
||||
fn2 = "ReadMe2.txt"
|
||||
|
||||
fp = fopen(fn1,"r")
|
||||
str = fread(fp, getFileSize(fp))
|
||||
fclose(fp)
|
||||
|
||||
fp = fopen(fn2,"w")
|
||||
fwrite(fp, str)
|
||||
fclose(fp)
|
||||
see "OK" + nl
|
||||
|
||||
func getFileSize fp
|
||||
c_filestart = 0
|
||||
c_fileend = 2
|
||||
fseek(fp,0,c_fileend)
|
||||
nfilesize = ftell(fp)
|
||||
fseek(fp,0,c_filestart)
|
||||
return nfilesize
|
||||
6
Task/File-input-output/Sidef/file-input-output.sidef
Normal file
6
Task/File-input-output/Sidef/file-input-output.sidef
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
var in = %f'input.txt'.open_r;
|
||||
var out = %f'output.txt'.open_w;
|
||||
|
||||
in.each { |line|
|
||||
out.print(line);
|
||||
};
|
||||
7
Task/File-input-output/Ursa/file-input-output.ursa
Normal file
7
Task/File-input-output/Ursa/file-input-output.ursa
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
decl file input output
|
||||
decl string contents
|
||||
input.open "input.txt"
|
||||
output.create "output.txt"
|
||||
output.open "output.txt"
|
||||
set contents (input.readall)
|
||||
out contents output
|
||||
4
Task/File-input-output/Wart/file-input-output.wart
Normal file
4
Task/File-input-output/Wart/file-input-output.wart
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
with infile "input.txt"
|
||||
with outfile "output.txt"
|
||||
whilet line (read_line)
|
||||
prn line
|
||||
1
Task/File-input-output/jq/file-input-output-1.jq
Normal file
1
Task/File-input-output/jq/file-input-output-1.jq
Normal file
|
|
@ -0,0 +1 @@
|
|||
jq -M --raw-input --raw-output '. as $line | $line' input.txt > output.txt
|
||||
1
Task/File-input-output/jq/file-input-output-2.jq
Normal file
1
Task/File-input-output/jq/file-input-output-2.jq
Normal file
|
|
@ -0,0 +1 @@
|
|||
jq -M '. as $line | $line' input.txt > output.txt
|
||||
Loading…
Add table
Add a link
Reference in a new issue