Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def nawiasy(xs: List[Char]): List[Char]={
- if(xs==Nil) return Nil
- else{
- if(xs.head=='(' || xs.head==')') return xs.head::nawiasy(xs.tail)
- else return nawiasy(xs.tail)
- }
- }
- def zliczanie(x: Int, xs: List[Char]): Int = {
- if(xs==Nil) return x
- else{
- if(x<0) return x
- else{
- if(xs.head=='(') return zliczanie(x+1,xs.tail)
- else return zliczanie(x-1,xs.tail)
- }
- }
- }
- def setZero(): Int = 0
- def balance(xs: List[Char])= zliczanie(setZero(),nawiasy(xs))==0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement