Sort an outline at every level: Difference between revisions
m
syntax highlighting fixup automation
(J draft) |
Thundergnat (talk | contribs) m (syntax highlighting fixup automation) |
||
Line 117:
=={{header|AutoHotkey}}==
<
;-----------------------
; get Delim, Error Check
Line 169:
result.=delim
return result
}</
Examples: "Example of Data_2"<
(
zeta
Line 186:
MsgBox % Sort_an_outline(Data_2)
MsgBox % Sort_an_outline(Data_2, 1)
return</
Output: tabulated for ease of reading, actual output is text only, Error check returns first line with inconsistent delimiter!<pre>
======================================================================================================
Line 225:
=={{header|Go}}==
{{trans|Wren}}
<
import (
Line 416:
fmt.Println("\nSecond unspecified outline, descending sort:")
sortedOutline(outline4, false)
}</
{{out}}
Line 536:
=={{header|Haskell}}==
<
import Data.Tree (Tree(..), foldTree)
Line 692:
| x <- textLines
, s <- [T.takeWhile isSpace x]
, 0 /= T.length s ]</
{{Out}}
<pre>Four-spaced (A -> Z):
Line 771:
=={{header|J}}==
Implementation:<
((=<./)y (1 i.~ -.@e.)S:0 m) m {{
({.y),<m parse2^:(*@#)}.y
Line 793:
sortout=: {{ if. L.y do. u~ ({."1 y),.u sortout each}."1 y else. u~y end. }}
unparse=: {{ ;<S:0 y }}</
Task examples (task data defined below):<
alpha
epsilon
Line 857:
gamma
delta
</syntaxhighlight>
Data for task examples:
<
zeta
beta
Line 915:
iota
epsilon
}}</
=={{header|Julia}}==
A <code>for</code> loop was used in the constructor, and recursive functions for sorting and printing.
<
abstract type Entry end
Line 1,072:
println(y)
end
</
<pre>
Given the text:
Line 1,182:
There are several differences between the Julia original and our transcription. Most are due to the fact that Nim way to do some things is different of the Julia way to do it.
<
type
Line 1,346:
epsilon""")
except ValueError:
echo getCurrentExceptionMsg()</
{{out}}
Line 1,453:
=={{header|Perl}}==
<
use strict; # https://rosettacode.org/wiki/Sort_an_outline_at_every_level
Line 1,538:
theta
iota
epsilon</
{{out}}
<pre>
Line 1,636:
=={{header|Phix}}==
<!--<
<span style="color: #008080;">without</span> <span style="color: #008080;">javascript_semantics</span> <span style="color: #000080;font-style:italic;">-- (tab chars are browser kryptonite)</span>
<span style="color: #008080;">procedure</span> <span style="color: #000000;">print_children</span><span style="color: #0000FF;">(</span><span style="color: #004080;">sequence</span> <span style="color: #000000;">lines</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">children</span><span style="color: #0000FF;">,</span> <span style="color: #004080;">string</span> <span style="color: #000000;">indent</span><span style="color: #0000FF;">,</span> <span style="color: #004080;">bool</span> <span style="color: #000000;">bRev</span><span style="color: #0000FF;">)</span>
Line 1,718:
<span style="color: #000000;">test</span><span style="color: #0000FF;">(</span><span style="color: #000000;">lines</span><span style="color: #0000FF;">)</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span>
<!--</
{{out}}
<pre>
Line 1,783:
=={{header|Python}}==
<
Line 2,199:
# MAIN ---
if __name__ == '__main__':
main()</
{{Out}}
<pre>4-space indented (A -> Z):
Line 2,278:
* Routine(s) to output the data structure in the desire sort order.
<syntaxhighlight lang="raku"
zeta
beta
Line 2,383:
multi pretty-print (Str $struct, :$level = 0, :$ws = ' ', :$desc = False) {
say $ws x $level , $struct;
}</
{{out}}
<pre>=======================================================
Line 2,497:
{{libheader|Wren-sort}}
{{libheader|Wren-fmt}}
<
import "/fmt" for Fmt
Line 2,651:
System.print("\nSecond unspecified outline, descending sort:")
sortedOutline.call(outline4, false)</
{{out}}
|