I write program for searching in index list of tuple by binary search I write and work fine
superBubble::(Ord t) =>[[t]]->[[t]]
superBubble a=map bubbleSort a
combining::[BookInfo]->[Int]
combining books= bubbleSort(map index books)
binsearch :: [Int] -> Int -> Int -> Int -> Int -- list, value, low, high, return int
binsearch xs value low high
| high < low = -1
| xs!!mid > value = binsearch xs value low (mid-1)
| xs!!mid < value = binsearch xs value (mid+1) high
| otherwise = mid
where
mid = low + ((high - low) `div` 2)
final::[BookInfo]->Int->Int->Int->Int
final vs key s r= binsearch concat( combining vs) key s r
and the other functions work propaply but when i add it to the hole give me an error
the error is unexcpted ‘|’ the first one but why?
The lines from
binsearch ::are indented one more space than the lines before it. Unindent each of those lines by one space.Additionally, the lines from
final::onwards are indented two more spaces than the initial lines. Unindent each of these lines by two spaces.Finally, as Daniel points out, you have a
-<in yourfinal::line, instead of a->. (Which you have now corrected in your posted code, thus confusing anyone who looks at this question in future.)Correct code:
(And you need to include definitions of
bubbleSort,BookInfoandindexas well.)Why is your indentation an error?
Because it makes
binsearchlook as if it is part of the value ofcombining, instead of a separate function. The first|is the first character that can’t possibly be part of an expression.