Fixed length records: Difference between revisions
Content deleted Content added
→{{header|TXR}}: Forth blocks task. |
→{{header|jq}}: -j |
||
Line 727:
=={{header|jq}}==
To read the raw input and write out raw strings, the command-line options -R (raw input), -
jq -
program.jq:
Currently gojq does not include the `_nwise/1` filter provided by jq, and in any case jq's implementation is suboptimal,
so we define `nwise` here so that it can be used for both array and string inputs. Notice that the inner helper function, `n`, has arity 0, allowing jq's tail-call optimization to work.
<syntaxhighlight lang="jq">def cut($n):
def nwise($n):
def
</syntaxhighlight>
To show that this does indeed work, the output of `/bin/dd cbs=80 conv=unblock` is shown:
{{output}}
<pre>
8.........7.........6.........5.........4.........3.........2.........1...1 eniL
2 eniL
3 eniL
4 eniL
6 eniL
▲cut(80) | explode | reverse | implode;</syntaxhighlight>
7 eniL
............................................................8 enil detnednI
NIGRAM TR 9 eniL
1+1 records in
1+1 records out
644 bytes transferred in 0.030319 secs (21241 bytes/sec)
</pre>
=={{header|Julia}}==
|