From ae9320aba7807963a8cdd3c56de2802156befc82 Mon Sep 17 00:00:00 2001 From: Eric Berquist Date: Thu, 9 Aug 2018 16:43:18 -0400 Subject: [PATCH 1/3] Racket should be highlighted as Scheme. --- contents/bubble_sort/bubble_sort.md | 4 ++-- contents/bubble_sort/code/racket/bubbleSort.rkt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/contents/bubble_sort/bubble_sort.md b/contents/bubble_sort/bubble_sort.md index 20716a107..104fca6f5 100644 --- a/contents/bubble_sort/bubble_sort.md +++ b/contents/bubble_sort/bubble_sort.md @@ -33,7 +33,7 @@ This means that we need to go through the vector $$\mathcal{O}(n^2)$$ times with {% sample lang="go" %} [import:7-21, lang:"golang"](code/go/bubbleSort.go) {% sample lang="racket" %} -[import:6-19, lang:"racket"](code/racket/bubbleSort.rkt) +[import:6-19, lang:"scheme"](code/racket/bubbleSort.rkt) {% sample lang="swift" %} [import:1-13, lang:"swift"](code/swift/bubblesort.swift) {% sample lang="ti83b" %} @@ -82,7 +82,7 @@ Program.cs {% sample lang="go" %} [import, lang:"golang"](code/go/bubbleSort.go) {% sample lang="racket" %} -[import, lang:"racket"](code/racket/bubbleSort.rkt) +[import, lang:"scheme"](code/racket/bubbleSort.rkt) {% sample lang="swift" %} [import, lang:"swift"](code/swift/bubblesort.swift) {% sample lang="ti83b" %} diff --git a/contents/bubble_sort/code/racket/bubbleSort.rkt b/contents/bubble_sort/code/racket/bubbleSort.rkt index 458fdf931..320cddc78 100644 --- a/contents/bubble_sort/code/racket/bubbleSort.rkt +++ b/contents/bubble_sort/code/racket/bubbleSort.rkt @@ -16,6 +16,6 @@ [r (drop l 2)]) (cond [(= (- n counter) 2) (cons (min x y) (cons (max x y) r))] [(cons (min x y) (pass (cons (max x y) r) (+ counter 1) n))]))) - + ((lambda (x) (display (bubbleSort x))) (read)) From 9b3e2613785999b6d50e0f7b0c17446a9f4c9769 Mon Sep 17 00:00:00 2001 From: Eric Berquist Date: Thu, 9 Aug 2018 16:44:25 -0400 Subject: [PATCH 2/3] Missing quote for Ruby syntax highlighting directive --- contents/bubble_sort/bubble_sort.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contents/bubble_sort/bubble_sort.md b/contents/bubble_sort/bubble_sort.md index 104fca6f5..666499c39 100644 --- a/contents/bubble_sort/bubble_sort.md +++ b/contents/bubble_sort/bubble_sort.md @@ -88,7 +88,7 @@ Program.cs {% sample lang="ti83b" %} [import, lang:"ti-83_basic"](code/ti83basic/BUBLSORT.txt) {% sample lang="ruby" %} -[import, lang:ruby"](code/ruby/bubble.rb) +[import, lang:"ruby"](code/ruby/bubble.rb) {% sample lang="crystal" %} [import, lang:"crystal"](code/crystal/bubble.cr) {% sample lang="php" %} From 64be69ac5dccafca851dcb11ca31cfd22f4e3cce Mon Sep 17 00:00:00 2001 From: Eric Berquist Date: Thu, 9 Aug 2018 16:50:54 -0400 Subject: [PATCH 3/3] Run code in MATLAB bubble sort implementation --- contents/bubble_sort/bubble_sort.md | 2 +- contents/bubble_sort/code/matlab/bubblesort.m | 28 +++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/contents/bubble_sort/bubble_sort.md b/contents/bubble_sort/bubble_sort.md index 666499c39..d706c6f4b 100644 --- a/contents/bubble_sort/bubble_sort.md +++ b/contents/bubble_sort/bubble_sort.md @@ -21,7 +21,7 @@ This means that we need to go through the vector $$\mathcal{O}(n^2)$$ times with {% sample lang="py" %} [import:4-9, lang:"python"](code/python/bubblesort.py) {% sample lang="m" %} -[import:11-23, lang:"matlab"](code/matlab/bubblesort.m) +[import:1-13, lang:"matlab"](code/matlab/bubblesort.m) {% sample lang="hs" %} [import, lang:"haskell"](code/haskell/bubbleSort.hs) {% sample lang="cpp" %} diff --git a/contents/bubble_sort/code/matlab/bubblesort.m b/contents/bubble_sort/code/matlab/bubblesort.m index 5e430622b..4c7378a48 100644 --- a/contents/bubble_sort/code/matlab/bubblesort.m +++ b/contents/bubble_sort/code/matlab/bubblesort.m @@ -1,16 +1,6 @@ -function main() - array = floor( rand(1,7)*100 ); - disp('Before Sorting:') - disp(array) - - array = bubble_sort(array); - disp('After Sorting') - disp(array) -end - -function sorted_array = bubble_sort(array) - for i=1:length(array) - for j=1:length(array)-i +function sorted_array = bubblesort(array) + for i = 1 : length(array) + for j = 1 : length(array) - i if array(j) > array(j+1) % swap elements in the list temp = array(j); @@ -19,7 +9,17 @@ function main() end end end - sorted_array = array + sorted_array = array; end +function main() + array = floor(rand(1, 7) * 100); + disp('Before Sorting:') + disp(array) + + array = bubble_sort(array); + disp('After Sorting:') + disp(array) +end +main()