File tree 2 files changed +28
-0
lines changed
2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -51,6 +51,8 @@ In code, it looks something like this:
51
51
[ import:10-12, lang:"factor"] ( code/factor/bogo_sort.factor )
52
52
{% sample lang="f90" %}
53
53
[ import:24-32, lang:"fortran"] ( code/fortran/bogo.f90 )
54
+ {% sample lang="racket" %}
55
+ [ import:3-8, lang:"lisp"] ( code/racket/bogo_sort.rkt )
54
56
{% sample lang="st" %}
55
57
[ import:2-6, lang:"st"] ( code/smalltalk/bogosort.st )
56
58
{% endmethod %}
@@ -103,6 +105,8 @@ We are done here!
103
105
[ import, lang:"factor"] ( code/factor/bogo_sort.factor )
104
106
{% sample lang="f90" %}
105
107
[ import, lang:"fortran"] ( code/fortran/bogo.f90 )
108
+ {% sample lang="racket" %}
109
+ [ import, lang:"lisp"] ( code/racket/bogo_sort.rkt )
106
110
{% sample lang="st" %}
107
111
[ import, lang:"st"] ( code/smalltalk/bogosort.st )
108
112
{% endmethod %}
Original file line number Diff line number Diff line change
1
+ #lang racket
2
+
3
+ (define (bogo_sort l)
4
+ (if (is_sorted? l)
5
+ l
6
+ (bogo_sort (shuffle l))
7
+ )
8
+ )
9
+
10
+ (define (is_sorted? l)
11
+ (if (> (length l) 1 )
12
+ (if (> (first l) (second l))
13
+ false
14
+ (is_sorted? (rest l))
15
+ )
16
+ true
17
+ )
18
+ )
19
+
20
+ (define unsorted_list '(20 -3 50 1 -6 59 ))
21
+ (display "unsorted list: " )
22
+ (displayln unsorted_list)
23
+ (display "sorted list: " )
24
+ (displayln (bogo_sort unsorted_list))
You can’t perform that action at this time.
0 commit comments