Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,27 @@
|
|||
{def alt
|
||||
{lambda {:list}
|
||||
{if {A.empty? :list}
|
||||
then {A.new}
|
||||
else {A.addfirst! {A.first :list}
|
||||
{alt {A.rest {A.rest :list}}}} }}}
|
||||
-> alt
|
||||
|
||||
{def merge
|
||||
{lambda {:l1 :l2}
|
||||
{if {A.empty? :l2}
|
||||
then :l1
|
||||
else {if {< {A.first :l1} {A.first :l2}}
|
||||
then {A.addfirst! {A.first :l1} {merge :l2 {A.rest :l1}}}
|
||||
else {A.addfirst! {A.first :l2} {merge :l1 {A.rest :l2}}} }}}}
|
||||
-> merge
|
||||
|
||||
{def mergesort
|
||||
{lambda {:list}
|
||||
{if {A.empty? {A.rest :list}}
|
||||
then :list
|
||||
else {merge {mergesort {alt :list}}
|
||||
{mergesort {alt {A.rest :list}}}} }}}
|
||||
-> mergesort
|
||||
|
||||
{mergesort {A.new 8 1 5 3 9 0 2 7 6 4}}
|
||||
-> [0,1,2,3,4,5,6,7,8,9]
|
||||
Loading…
Add table
Add a link
Reference in a new issue