Skip to content

Commit

Permalink
use spaces instead of tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
mertcandav committed Aug 18, 2023
1 parent 221e901 commit 2b218a2
Show file tree
Hide file tree
Showing 30 changed files with 227 additions and 227 deletions.
12 changes: 6 additions & 6 deletions search/linear_search.jule
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
pub fn linear_search(s: []int, i: int): (pos: int) {
for j, x in s {
if x == i {
ret j
}
}
ret -1
for j, x in s {
if x == i {
ret j
}
}
ret -1
}
24 changes: 12 additions & 12 deletions sort/bubble_sort.jule
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
pub fn bubble_sort(mut s: []int): []int {
let mut swapped = true
for swapped {
swapped = false
let mut i = 0
for i < s.len-1; i++ {
if s[i+1] < s[i] {
s[i+1], s[i] = s[i], s[i+1]
swapped = true
}
}
}
let mut swapped = true
for swapped {
swapped = false
let mut i = 0
for i < s.len-1; i++ {
if s[i+1] < s[i] {
s[i+1], s[i] = s[i], s[i+1]
swapped = true
}
}
}

ret s
ret s
}
20 changes: 10 additions & 10 deletions sort/exchange_sort.jule
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
pub fn exchange_sort(mut s: []int): []int {
let mut i = 0
for i < s.len-1; i++ {
let mut j = i + 1
for j < s.len; j++ {
if s[i] > s[j] {
s[i], s[j] = s[j], s[i]
}
}
}
let mut i = 0
for i < s.len-1; i++ {
let mut j = i + 1
for j < s.len; j++ {
if s[i] > s[j] {
s[i], s[j] = s[j], s[i]
}
}
}

ret s
ret s
}
20 changes: 10 additions & 10 deletions sort/insertion_sort.jule
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
pub fn insertion_sort(mut s: []int): []int {
let mut current_index = 1
for current_index < s.len; current_index++ {
let temporary = s[current_index]
let mut iterator = current_index
for iterator > 0 && s[iterator-1] > temporary; iterator-- {
s[iterator] = s[iterator-1]
}
s[iterator] = temporary
}
let mut current_index = 1
for current_index < s.len; current_index++ {
let temporary = s[current_index]
let mut iterator = current_index
for iterator > 0 && s[iterator-1] > temporary; iterator-- {
s[iterator] = s[iterator-1]
}
s[iterator] = temporary
}

ret s
ret s
}
28 changes: 14 additions & 14 deletions sort/quick_sort.jule
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
pub fn quick_sort(mut s: []int): []int {
if s.len <= 1 {
ret s
}
if s.len <= 1 {
ret s
}

let mut i = -1
let last = s[s.len-1]
for j in s {
if s[j] <= last {
i++
s[i], s[j] = s[j], s[i]
}
}
let mut i = -1
let last = s[s.len-1]
for j in s {
if s[j] <= last {
i++
s[i], s[j] = s[j], s[i]
}
}

quick_sort(s[:i])
quick_sort(s[i+1:])
quick_sort(s[:i])
quick_sort(s[i+1:])

ret s
ret s
}
24 changes: 12 additions & 12 deletions sort/selection_sort.jule
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
pub fn selection_sort(mut s: []int): []int {
let mut i = 0
for i < s.len; i++ {
let mut min = i
let mut j = i + 1
for j < s.len; j++ {
if s[j] < s[min] {
min = j
}
}
let mut i = 0
for i < s.len; i++ {
let mut min = i
let mut j = i + 1
for j < s.len; j++ {
if s[j] < s[min] {
min = j
}
}

s[i], s[min] = s[min], s[i]
}
s[i], s[min] = s[min], s[i]
}

ret s
ret s
}
22 changes: 11 additions & 11 deletions sort/shell_sort.jule
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
pub fn shell_sort(mut s: []int): []int {
let mut d = int(s.len / 2)
for d > 0; d /= 2 {
let mut i = d
for i < s.len; i++ {
let mut j = i
for j >= d && s[j-d] > s[j]; j -= d {
s[j], s[j-d] = s[j-d], s[j]
}
}
}
let mut d = int(s.len / 2)
for d > 0; d /= 2 {
let mut i = d
for i < s.len; i++ {
let mut j = i
for j >= d && s[j-d] > s[j]; j -= d {
s[j], s[j-d] = s[j-d], s[j]
}
}
}

ret s
ret s
}
20 changes: 10 additions & 10 deletions sort/simple_sort.jule
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
pub fn simple_sort(mut s: []int): []int {
let mut i = 1
for i < s.len; i++ {
let mut j = 0
for j < s.len-1; j++ {
if s[i] < s[j] {
s[i], s[j] = s[j], s[i]
}
}
}
let mut i = 1
for i < s.len; i++ {
let mut j = 0
for j < s.len-1; j++ {
if s[i] < s[j] {
s[i], s[j] = s[j], s[i]
}
}
}

ret s
ret s
}
12 changes: 6 additions & 6 deletions test.jule
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ use tests::sort::{sort_package_tests}
use tests::string::{string_package_tests}

fn main() {
let mut tests = TestStack.new()
let mut tests = TestStack.new()

math_package_tests(tests)
search_package_tests(tests)
sort_package_tests(tests)
string_package_tests(tests)
math_package_tests(tests)
search_package_tests(tests)
sort_package_tests(tests)
string_package_tests(tests)

tests.do()
tests.do()
}
6 changes: 3 additions & 3 deletions tests/math/abs_test.jule
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use tests::{TestStack}
use math::{abs}

fn abs_tests(mut &tests: TestStack) {
tests.add("abs", fn(): bool {
ret abs(-12.2) == 12.2
})
tests.add("abs", fn(): bool {
ret abs(-12.2) == 12.2
})
}
8 changes: 4 additions & 4 deletions tests/math/median_test.jule
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ use tests::{TestStack}
use math::{median}

fn median_tests(mut &tests: TestStack) {
let slice = [2, 5, 2, 6, -4, -15, 1, -3]
let slice = [2, 5, 2, 6, -4, -15, 1, -3]

tests.add("median", fn(): bool {
ret median(clone(slice)) == 1.5
})
tests.add("median", fn(): bool {
ret median(clone(slice)) == 1.5
})
}
4 changes: 2 additions & 2 deletions tests/math/package_test.jule
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use tests::{TestStack}

pub fn math_package_tests(mut &tests: TestStack) {
abs_tests(tests)
median_tests(tests)
abs_tests(tests)
median_tests(tests)
}
14 changes: 7 additions & 7 deletions tests/search/linear_search_test.jule
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ use tests::{TestStack}
use search::{linear_search}

fn linear_search_tests(mut &tests: TestStack) {
let s = [9, 35, -0, 0, 98, 8935, -85, -9835, 64, 89]
let s = [9, 35, -0, 0, 98, 8935, -85, -9835, 64, 89]

tests.add("linear_search:(1)", fn(): bool {
ret linear_search(s, 90) == -1
})
tests.add("linear_search:(1)", fn(): bool {
ret linear_search(s, 90) == -1
})

tests.add("linear_search:(2)", fn(): bool {
ret linear_search(s, -85) == 6
})
tests.add("linear_search:(2)", fn(): bool {
ret linear_search(s, -85) == 6
})
}
2 changes: 1 addition & 1 deletion tests/search/package_test.jule
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use tests::{TestStack}

pub fn search_package_tests(mut &tests: TestStack) {
linear_search_tests(tests)
linear_search_tests(tests)
}
10 changes: 5 additions & 5 deletions tests/sort/bubble_sort_test.jule
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ use tests::{TestStack}
use sort::{bubble_sort}

fn bubble_sort_tests(mut &tests: TestStack) {
let mut unsorted = [9, 35, -0, 0, 98, 8935, -85, -9835, 64, 89]
let sorted = [-9835, -85, -0, 0, 9, 35, 64, 89, 98, 8935]
let mut unsorted = [9, 35, -0, 0, 98, 8935, -85, -9835, 64, 89]
let sorted = [-9835, -85, -0, 0, 9, 35, 64, 89, 98, 8935]

tests.add("bubble_sort", fn(): bool {
ret bubble_sort(unsorted) == sorted
})
tests.add("bubble_sort", fn(): bool {
ret bubble_sort(unsorted) == sorted
})
}
10 changes: 5 additions & 5 deletions tests/sort/exchange_sort_test.jule
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ use tests::{TestStack}
use sort::{exchange_sort}

fn exchange_sort_tests(mut &tests: TestStack) {
let mut unsorted = [9, 35, -0, 0, 98, 8935, -85, -9835, 64, 89]
let sorted = [-9835, -85, -0, 0, 9, 35, 64, 89, 98, 8935]
let mut unsorted = [9, 35, -0, 0, 98, 8935, -85, -9835, 64, 89]
let sorted = [-9835, -85, -0, 0, 9, 35, 64, 89, 98, 8935]

tests.add("exchange_sort", fn(): bool {
ret exchange_sort(unsorted) == sorted
})
tests.add("exchange_sort", fn(): bool {
ret exchange_sort(unsorted) == sorted
})
}
10 changes: 5 additions & 5 deletions tests/sort/insertion_sort_test.jule
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ use tests::{TestStack}
use sort::{insertion_sort}

fn insertion_sort_tests(mut &tests: TestStack) {
let mut unsorted = [9, 35, -0, 0, 98, 8935, -85, -9835, 64, 89]
let sorted = [-9835, -85, -0, 0, 9, 35, 64, 89, 98, 8935]
let mut unsorted = [9, 35, -0, 0, 98, 8935, -85, -9835, 64, 89]
let sorted = [-9835, -85, -0, 0, 9, 35, 64, 89, 98, 8935]

tests.add("insertion_sort", fn(): bool {
ret insertion_sort(unsorted) == sorted
})
tests.add("insertion_sort", fn(): bool {
ret insertion_sort(unsorted) == sorted
})
}
14 changes: 7 additions & 7 deletions tests/sort/package_test.jule
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use tests::{TestStack}

pub fn sort_package_tests(mut &tests: TestStack) {
bubble_sort_tests(tests)
exchange_sort_tests(tests)
insertion_sort_tests(tests)
quick_sort_tests(tests)
selection_sort_tests(tests)
shell_sort_tests(tests)
simple_sort_tests(tests)
bubble_sort_tests(tests)
exchange_sort_tests(tests)
insertion_sort_tests(tests)
quick_sort_tests(tests)
selection_sort_tests(tests)
shell_sort_tests(tests)
simple_sort_tests(tests)
}
10 changes: 5 additions & 5 deletions tests/sort/quick_sort_test.jule
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ use tests::{TestStack}
use sort::{quick_sort}

fn quick_sort_tests(mut &tests: TestStack) {
let mut unsorted = [9, 35, -0, 0, 98, 8935, -85, -9835, 64, 89]
let sorted = [-9835, -85, -0, 0, 9, 35, 64, 89, 98, 8935]
let mut unsorted = [9, 35, -0, 0, 98, 8935, -85, -9835, 64, 89]
let sorted = [-9835, -85, -0, 0, 9, 35, 64, 89, 98, 8935]

tests.add("quick_sort", fn(): bool {
ret quick_sort(unsorted) == sorted
})
tests.add("quick_sort", fn(): bool {
ret quick_sort(unsorted) == sorted
})
}
10 changes: 5 additions & 5 deletions tests/sort/selection_sort_test.jule
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ use tests::{TestStack}
use sort::{selection_sort}

fn selection_sort_tests(mut &tests: TestStack) {
let mut unsorted = [9, 35, -0, 0, 98, 8935, -85, -9835, 64, 89]
let sorted = [-9835, -85, -0, 0, 9, 35, 64, 89, 98, 8935]
let mut unsorted = [9, 35, -0, 0, 98, 8935, -85, -9835, 64, 89]
let sorted = [-9835, -85, -0, 0, 9, 35, 64, 89, 98, 8935]

tests.add("selection_sort", fn(): bool {
ret selection_sort(unsorted) == sorted
})
tests.add("selection_sort", fn(): bool {
ret selection_sort(unsorted) == sorted
})
}
Loading

0 comments on commit 2b218a2

Please sign in to comment.