Just in time processing on a character stream: Difference between revisions

Added 11l
(→‎{{header|jq}}: emit_until)
(Added 11l)
Line 11:
 
This task was inspired by the movie "[[wp:National_Treasure_%28film%29|National Treasure]]", which refers to a "[[wp:Book cipher|book cipher]]".
 
=={{header|11l}}==
{{trans|Python}}
 
<lang 11l>T UserInput
Int formFeed
Int lineFeed
Int tab
Int space
 
F (chunk)
.formFeed = chunk[0]
.lineFeed = chunk[1]
.tab = chunk[2]
.space = chunk[3]
 
F String()
R ‘(ff=#.; lf=#.; tb=#.; sp#.)’.format(.formFeed, .lineFeed, .tab, .space)
 
F chunks(l, n)
[[Int]] r
L(i) (0 .< l.len).step(n)
r.append(l[i .+ n])
R r
 
F getUserInput()
V h = ‘0 18 0 0 0 68 0 1 0 100 0 32 0 114 0 45 0 38 0 26 0 16 0 21 0 17 0 59 0 11 ’""
‘0 29 0 102 0 0 0 10 0 50 0 39 0 42 0 33 0 50 0 46 0 54 0 76 0 47 0 84 2 28’
V ha = h.split(‘ ’).map(Int)
R chunks(ha, 4).map(chunk -> UserInput(chunk))
 
F decode(filename, uiList)
V f = File(filename, ‘r’)
V text = f.read()
 
F decode2(ui)
V f = 0
V l = 0
V t = 0
V s = 0
L(c) @text
I f == ui.formFeed & l == ui.lineFeed & t == ui.tab & s == ui.space
I c == ‘!’
R 0B
print(c, end' ‘’)
R 1B
I c.code == 0'C
f = f + 1
l = 0
t = 0
s = 0
E I c == "\n"
l = l + 1
t = 0
s = 0
E I c == "\t"
t = t + 1
s = 0
E
s = s + 1
R 0B
 
L(ui) uiList
I !decode2(ui)
L.break
print()
 
V uiList = getUserInput()
decode(‘theRaven.txt’, uiList)</lang>
 
{{out}}
<pre>
Silence-Dogood.
</pre>
 
=={{header|C}}==
1,481

edits