Skip to content

Commit

Permalink
const
Browse files Browse the repository at this point in the history
  • Loading branch information
keiravillekode committed Oct 1, 2024
1 parent 36b6ae1 commit 50d9081
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 14 deletions.
2 changes: 1 addition & 1 deletion exercises/practice/allergies/run_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ fn test_list_everything() {
Allergen.strawberries, Allergen.tomatoes, Allergen.chocolate, Allergen.pollen, Allergen.cats])
}

fn compare(left voidptr, right voidptr) int {
fn compare(left &Allergen, right &Allergen) int {
return int(left) - int(right)
}

Expand Down
1 change: 0 additions & 1 deletion exercises/practice/custom-set/.meta/example.v
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,3 @@ pub fn (s CustomSet[T]) is_subset[T](other CustomSet[T]) bool {
pub fn (s CustomSet[T]) is_disjoint[T](other CustomSet[T]) bool {
return s.intersection(other).is_empty()
}

8 changes: 3 additions & 5 deletions exercises/practice/custom-set/run_test.v
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
module main

const (
empty = CustomSet.new([]int{})
another_empty = CustomSet.new([]int{})
non_empty = CustomSet.new([1])
)
const empty = CustomSet.new([]int{})
const another_empty = CustomSet.new([]int{})
const non_empty = CustomSet.new([1])

// is_empty

Expand Down
13 changes: 6 additions & 7 deletions exercises/practice/isbn-verifier/.meta/example.v
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ module main
import arrays { group, sum }
import regex { regex_opt }

const (
isbn_len = 10
const isbn_len = 10

/*
/*
Using a regular expression, I now have two problems:
https://blog.codinghorror.com/regular-expressions-now-you-have-two-problems/
Expand All @@ -15,10 +14,10 @@ const (
- length check
- character validation
*/
isbn_re = regex_opt(r'^\d{9}(\d|X)$') or { panic('Invalid ISBN-10 regular expression') }
weights = []int{len: isbn_len, init: isbn_len - index} // [10, 9, 8, ..., 1]
zero = int(`0`)
)
const isbn_re = regex_opt(r'^\d{9}(\d|X)$') or { panic('Invalid ISBN-10 regular expression') }
const weights = []int{len: isbn_len, init: isbn_len - index} // [10, 9, 8, ..., 1]

const zero = int(`0`)

// convert single digit (`0`...`9`) to its integer equivalent.
fn digit_to_int(d u8) int {
Expand Down

0 comments on commit 50d9081

Please sign in to comment.