File tree 2 files changed +19
-0
lines changed
2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -69,6 +69,8 @@ In code, it looks something like this:
69
69
[ import:12-16, lang:"scala"] ( code/scala/bogo.scala )
70
70
{% sample lang="go" %}
71
71
[ import:27-31, lang:"go"] ( code/go/bogo_sort.go )
72
+ {% sample lang="coco" %}
73
+ [ import:6-8, lang:"coconut"] ( code/coconut/bogo.coco )
72
74
{% endmethod %}
73
75
74
76
That's it.
@@ -137,6 +139,8 @@ We are done here!
137
139
[ import, lang:"scala"] ( code/scala/bogo.scala )
138
140
{% sample lang="go" %}
139
141
[ import, lang:"go"] ( code/go/bogo_sort.go )
142
+ {% sample lang="coco" %}
143
+ [ import, lang:"coconut"] ( code/coconut/bogo.coco )
140
144
{% endmethod %}
141
145
142
146
Original file line number Diff line number Diff line change
1
+ import random
2
+
3
+
4
+ is_sorted = l -> (l, l[1:]) |*> zip |> map$(t -> t[0] <= t[1]) |> all
5
+
6
+ def bogo_sort(a):
7
+ while not is_sorted(a):
8
+ random.shuffle(a)
9
+
10
+
11
+ if __name__ == '__main__':
12
+ a = [1, 3, 2, 4]
13
+ print('Unsorted:', a)
14
+ bogo_sort(a)
15
+ print('Sorted:', a)
You can’t perform that action at this time.
0 commit comments