File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed
Expand file tree Collapse file tree 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:
5151[ import:10-12, lang:"factor"] ( code/factor/bogo_sort.factor )
5252{% sample lang="f90" %}
5353[ import:24-32, lang:"fortran"] ( code/fortran/bogo.f90 )
54+ {% sample lang="racket" %}
55+ [ import:3-8, lang:"lisp"] ( code/racket/bogo_sort.rkt )
5456{% sample lang="st" %}
5557[ import:2-6, lang:"st"] ( code/smalltalk/bogosort.st )
5658{% endmethod %}
@@ -103,6 +105,8 @@ We are done here!
103105[ import, lang:"factor"] ( code/factor/bogo_sort.factor )
104106{% sample lang="f90" %}
105107[ import, lang:"fortran"] ( code/fortran/bogo.f90 )
108+ {% sample lang="racket" %}
109+ [ import, lang:"lisp"] ( code/racket/bogo_sort.rkt )
106110{% sample lang="st" %}
107111[ import, lang:"st"] ( code/smalltalk/bogosort.st )
108112{% 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