Skip to content

Commit 07546e1

Browse files
authored
Fix semantics of binarysearch.dana (#74)
- Add return types to the declerations of 'partition' and 'binarySearch' function definitions. - Correct a type mismatch in the array population loop by changing the termination assignment from the byte literal '\0' to the integer 0.
1 parent a20fc3a commit 07546e1

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

dana/programs/binarysearch.dana

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
def main
22

3-
def partition: arr as int [], low high as int
3+
def partition is int: arr as int [], low high as int
44
var pivot i j is int
55
pivot := arr[high]
66
i := low - 1
@@ -27,7 +27,7 @@ def main
2727
a := b
2828
b := t
2929

30-
def binarySearch: arr as int [], low high x as int
30+
def binarySearch is int: arr as int [], low high x as int
3131
var mid is int
3232
loop:
3333
if low > high: break
@@ -52,7 +52,7 @@ def main
5252
nums[k] := readInteger()
5353
k := k + 1
5454
else:
55-
nums[k] := '\0'
55+
nums[k] := 0
5656
break
5757

5858
writeString: "\n"

0 commit comments

Comments
 (0)