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
1
Task/Read-entire-file/8th/read-entire-file.8th
Normal file
1
Task/Read-entire-file/8th/read-entire-file.8th
Normal file
|
|
@ -0,0 +1 @@
|
|||
"somefile.txt" f:slurp >s
|
||||
10
Task/Read-entire-file/FreeBASIC/read-entire-file.freebasic
Normal file
10
Task/Read-entire-file/FreeBASIC/read-entire-file.freebasic
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
' FB 1.05.0 Win64
|
||||
|
||||
Open "input.txt" For Input Encoding "ascii" As #1
|
||||
Dim fileLen As LongInt = Lof(1) '' get file length in bytes
|
||||
Dim buffer As String = Space(fileLen) '' allocate a string of size 'fileLen' bytes
|
||||
Get #1, 1, buffer '' read all data from start of file into the buffer
|
||||
Print buffer '' print to console
|
||||
buffer = "" '' release memory used by setting buffer to empty
|
||||
Close #1
|
||||
Sleep
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
include "ConsoleWindow"
|
||||
|
||||
local fn ReadTextFile
|
||||
dim as CFURLRef fileRef
|
||||
dim as Handle h
|
||||
dim as CFStringRef cfStr : cfStr = NULL
|
||||
dim as long fileLen
|
||||
|
||||
if ( files$( _CFURLRefOpen, "TEXT", "Select text file...", @fileRef ) )
|
||||
open "i", 2, fileRef
|
||||
fileLen = lof( 2, 1 )
|
||||
h = fn NewHandleClear( fileLen )
|
||||
if ( h )
|
||||
read file 2, [h], fileLen
|
||||
close #2
|
||||
cfStr = fn CFStringCreateWithBytes( _kCFAllocatorDefault, #[h], fn GetHandleSize(h), _kCFStringEncodingMacRoman, _false )
|
||||
fn DisposeH( h )
|
||||
end if
|
||||
else
|
||||
// User canceled
|
||||
end if
|
||||
|
||||
fn HIViewSetText( sConsoleHITextView, cfStr )
|
||||
CFRelease( cfStr )
|
||||
end fn
|
||||
|
||||
fn ReadTextFile
|
||||
1
Task/Read-entire-file/LFE/read-entire-file.lfe
Normal file
1
Task/Read-entire-file/LFE/read-entire-file.lfe
Normal file
|
|
@ -0,0 +1 @@
|
|||
(set `#(ok ,data) (file:read_file "myfile.txt"))
|
||||
2
Task/Read-entire-file/Lasso/read-entire-file.lasso
Normal file
2
Task/Read-entire-file/Lasso/read-entire-file.lasso
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
local(f) = file('foo.txt')
|
||||
#f->readString
|
||||
13
Task/Read-entire-file/Lingo/read-entire-file.lingo
Normal file
13
Task/Read-entire-file/Lingo/read-entire-file.lingo
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
----------------------------------------
|
||||
-- Reads whole file, returns string
|
||||
-- @param {string} tFile
|
||||
-- @return {string|false}
|
||||
----------------------------------------
|
||||
on readFile (tFile)
|
||||
fp = xtra("fileIO").new()
|
||||
fp.openFile(tFile, 1)
|
||||
if fp.status() then return false
|
||||
res = fp.readFile()
|
||||
fp.closeFile()
|
||||
return res
|
||||
end
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
put URL "file:///usr/share/dict/words" into tVar
|
||||
put the number of lines of tVar
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
local tFile,tLinecount
|
||||
put "/usr/share/dict/words" into tFile
|
||||
open file tFile for text read
|
||||
read from file tFile until EOF
|
||||
put the number of lines of it -- file contents held in "it" variable
|
||||
close file tFile
|
||||
1
Task/Read-entire-file/Nim/read-entire-file.nim
Normal file
1
Task/Read-entire-file/Nim/read-entire-file.nim
Normal file
|
|
@ -0,0 +1 @@
|
|||
readFile(filename)
|
||||
1
Task/Read-entire-file/Panda/read-entire-file.panda
Normal file
1
Task/Read-entire-file/Panda/read-entire-file.panda
Normal file
|
|
@ -0,0 +1 @@
|
|||
file:readme.txt .text
|
||||
4
Task/Read-entire-file/Phix/read-entire-file.phix
Normal file
4
Task/Read-entire-file/Phix/read-entire-file.phix
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
constant fn = open(command_line()[2],"rb")
|
||||
?get_text(fn)
|
||||
close(fn)
|
||||
{} = wait_key()
|
||||
4
Task/Read-entire-file/Ring/read-entire-file-1.ring
Normal file
4
Task/Read-entire-file/Ring/read-entire-file-1.ring
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
# Read the file
|
||||
cStr = read("myfile.txt")
|
||||
# print the file content
|
||||
See cStr
|
||||
1
Task/Read-entire-file/Ring/read-entire-file-2.ring
Normal file
1
Task/Read-entire-file/Ring/read-entire-file-2.ring
Normal file
|
|
@ -0,0 +1 @@
|
|||
cStr = read("myfile.txt") See cStr
|
||||
1
Task/Read-entire-file/Ring/read-entire-file-3.ring
Normal file
1
Task/Read-entire-file/Ring/read-entire-file-3.ring
Normal file
|
|
@ -0,0 +1 @@
|
|||
See read("myfile.txt")
|
||||
3
Task/Read-entire-file/Sidef/read-entire-file-1.sidef
Normal file
3
Task/Read-entire-file/Sidef/read-entire-file-1.sidef
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
var file = File.new(__FILE__);
|
||||
var content = file.open_r.slurp;
|
||||
print content;
|
||||
3
Task/Read-entire-file/Sidef/read-entire-file-2.sidef
Normal file
3
Task/Read-entire-file/Sidef/read-entire-file-2.sidef
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
var file = File(__FILE__)
|
||||
var content = file.read(:utf8)
|
||||
print content
|
||||
|
|
@ -0,0 +1 @@
|
|||
let contents = readfile("foo.txt");
|
||||
6
Task/Read-entire-file/Swift/read-entire-file.swift
Normal file
6
Task/Read-entire-file/Swift/read-entire-file.swift
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
import Foundation
|
||||
|
||||
let path = "~/input.txt".stringByExpandingTildeInPath
|
||||
if let string = String(contentsOfFile: path, encoding: NSUTF8StringEncoding) {
|
||||
println(string) // print contents of file
|
||||
}
|
||||
4
Task/Read-entire-file/Ursa/read-entire-file.ursa
Normal file
4
Task/Read-entire-file/Ursa/read-entire-file.ursa
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
decl string contents
|
||||
decl file f
|
||||
f.open "filename.txt"
|
||||
set contents (f.readall)
|
||||
4
Task/Read-entire-file/Wart/read-entire-file.wart
Normal file
4
Task/Read-entire-file/Wart/read-entire-file.wart
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
with infile "x"
|
||||
with outstring
|
||||
whilet line (read_line)
|
||||
prn line
|
||||
1
Task/Read-entire-file/jq/read-entire-file-1.jq
Normal file
1
Task/Read-entire-file/jq/read-entire-file-1.jq
Normal file
|
|
@ -0,0 +1 @@
|
|||
jq -R -s . input.txt
|
||||
1
Task/Read-entire-file/jq/read-entire-file-2.jq
Normal file
1
Task/Read-entire-file/jq/read-entire-file-2.jq
Normal file
|
|
@ -0,0 +1 @@
|
|||
jq -R . input.txt | jq -s .
|
||||
1
Task/Read-entire-file/jq/read-entire-file-3.jq
Normal file
1
Task/Read-entire-file/jq/read-entire-file-3.jq
Normal file
|
|
@ -0,0 +1 @@
|
|||
jq -R -s 'split("\n")' input.txt
|
||||
Loading…
Add table
Add a link
Reference in a new issue