73 lines
1.6 KiB
Plaintext
73 lines
1.6 KiB
Plaintext
( ( self-referential
|
|
= seq N next
|
|
. ( next
|
|
= R S d f
|
|
. 0:?S
|
|
& whl
|
|
' (@(!arg:%@?d ?arg)&(.!d)+!S:?S)
|
|
& :?R
|
|
& whl
|
|
' ( !S:#?f*(.?d)+?S
|
|
& !f !d !R:?R
|
|
)
|
|
& str$!R
|
|
)
|
|
& 1:?N
|
|
& !arg:?seq
|
|
& whl
|
|
' ( next$!arg:?arg
|
|
& ~(!seq:? !arg ?)
|
|
& !arg !seq:?seq
|
|
& 1+!N:?N
|
|
)
|
|
& (!seq.!N)
|
|
)
|
|
& ( Perm
|
|
= permutations S p
|
|
. :?permutations
|
|
& ( perm
|
|
= prefix List original A Z p
|
|
. !arg:(?prefix.)
|
|
& str$!prefix:?p
|
|
& (!S:?+(.!p)+?|(.!p)+!S:?S)
|
|
| !arg:(0 ?.?)&
|
|
| !arg:(?prefix.?List:?original)
|
|
& whl
|
|
' ( @(!List:%?A ?Z)
|
|
& perm$(!prefix !A.!Z)
|
|
& str$(!Z !A):~!original:?List
|
|
)
|
|
)
|
|
& 0:?S
|
|
& perm$(.!arg)
|
|
& :?permutations
|
|
& whl
|
|
' ( !S:?*(.?p)+?S
|
|
& !p !permutations:?permutations
|
|
)
|
|
& !permutations
|
|
)
|
|
& -1:?i:?max
|
|
& :?seqs
|
|
& whl
|
|
' ( 1+!i:<1000000:?i
|
|
& ( @(!i:? %@?a >%@!a ?)
|
|
| self-referential$!i
|
|
: ( ?seq
|
|
. ( >!max:?max&:?seqs
|
|
| !max
|
|
)
|
|
& ( "Seed Value(s):" Perm$!i
|
|
. "Sequence: (same for all three seeds except for first element)
|
|
"
|
|
!seq
|
|
)
|
|
!seqs
|
|
: ?seqs
|
|
)
|
|
|
|
|
)
|
|
)
|
|
& out$("Iterations:" !max !seqs)
|
|
);
|