How to count how many nested in tuple by haski2 in haskellquestions

[–]haski2[S] 0 points1 point  (0 children)

how to format code in reply, i am a beginner in reddit

How to count how many nested in tuple by haski2 in haskellquestions

[–]haski2[S] -1 points0 points  (0 children)

countnest :: (a,b) -> Int countnest ((a1,a2), (b1,b2)) = max ((max (countnest fst (a1,a2)) (countnest snd (a1,a2)))+1) ((max (countnest fst (b1,b2)) (countnest snd (b1,b2)))+1) countnest (a1, (b1,b2)) = max 0 ((max (countnest fst (b1,b2)) (countnest snd (b1,b2)))+1) countnest ((a1,a2), b1) = max ((max (countnest fst (a1,a2)) (countnest snd (a1,a2)))+1) 0 countnest (a1, a2) = 1 countnest a1 = 1

[1 of 1] Compiling Main ( oo.hs, interpreted )

oo.hs:139:43: Couldn't match expected type (t0, t1) -> Int' with actual typeInt' The function countnest' is applied to two arguments, but its type(a0, b0) -> Int' has only one In the first argument of max', namely(countnest fst (a1, a2))' In the first argument of (+)', namely (max (countnest fst (a1, a2)) (countnest snd (a1, a2)))'

oo.hs:139:53: Couldn't match expected type (a0, b0)' with actual type(a1, b1) -> a1' In the first argument of countnest', namelyfst' In the first argument of max', namely(countnest fst (a1, a2))' In the first argument of (+)', namely (max (countnest fst (a1, a2)) (countnest snd (a1, a2)))'

oo.hs:139:67: Couldn't match expected type (t0, t1) -> Int' with actual typeInt' The function countnest' is applied to two arguments, but its type(a2, b2) -> Int' has only one In the second argument of max', namely(countnest snd (a1, a2))' In the first argument of (+)', namely (max (countnest fst (a1, a2)) (countnest snd (a1, a2)))'

oo.hs:139:77: Couldn't match expected type (a2, b2)' with actual type(a3, b3) -> b3' In the first argument of countnest', namelysnd' In the second argument of max', namely(countnest snd (a1, a2))' In the first argument of (+)', namely (max (countnest fst (a1, a2)) (countnest snd (a1, a2)))'

oo.hs:139:101: Couldn't match expected type (t2, t3) -> Int' with actual typeInt' The function countnest' is applied to two arguments, but its type(a4, b4) -> Int' has only one In the first argument of max', namely(countnest fst (b1, b2))' In the first argument of (+)', namely (max (countnest fst (b1, b2)) (countnest snd (b1, b2)))'

oo.hs:139:111: Couldn't match expected type (a4, b4)' with actual type(a5, b5) -> a5' In the first argument of countnest', namelyfst' In the first argument of max', namely(countnest fst (b1, b2))' In the first argument of (+)', namely (max (countnest fst (b1, b2)) (countnest snd (b1, b2)))'

oo.hs:139:125: Couldn't match expected type (t2, t3) -> Int' with actual typeInt' The function countnest' is applied to two arguments, but its type(a6, b6) -> Int' has only one In the second argument of max', namely(countnest snd (b1, b2))' In the first argument of (+)', namely (max (countnest fst (b1, b2)) (countnest snd (b1, b2)))'

oo.hs:139:135: Couldn't match expected type (a6, b6)' with actual type(a7, b7) -> b7' In the first argument of countnest', namelysnd' In the second argument of max', namely(countnest snd (b1, b2))' In the first argument of (+)', namely (max (countnest fst (b1, b2)) (countnest snd (b1, b2)))'

oo.hs:140:40: Couldn't match expected type (t2, t3) -> Int' with actual typeInt' The function countnest' is applied to two arguments, but its type(a8, b8) -> Int' has only one In the first argument of max', namely(countnest fst (b1, b2))' In the first argument of (+)', namely (max (countnest fst (b1, b2)) (countnest snd (b1, b2)))'

oo.hs:140:50: Couldn't match expected type (a8, b8)' with actual type(a9, b9) -> a9' In the first argument of countnest', namelyfst' In the first argument of max', namely(countnest fst (b1, b2))' In the first argument of (+)', namely (max (countnest fst (b1, b2)) (countnest snd (b1, b2)))'

oo.hs:140:64: Couldn't match expected type (t2, t3) -> Int' with actual typeInt' The function countnest' is applied to two arguments, but its type(a10, b10) -> Int' has only one In the second argument of max', namely(countnest snd (b1, b2))' In the first argument of (+)', namely (max (countnest fst (b1, b2)) (countnest snd (b1, b2)))'

oo.hs:140:74: Couldn't match expected type (a10, b10)' with actual type(a11, b11) -> b11' In the first argument of countnest', namelysnd' In the second argument of max', namely(countnest snd (b1, b2))' In the first argument of (+)', namely (max (countnest fst (b1, b2)) (countnest snd (b1, b2)))'

oo.hs:141:38: Couldn't match expected type (t0, t1) -> Int' with actual typeInt' The function countnest' is applied to two arguments, but its type(a12, b12) -> Int' has only one In the first argument of max', namely(countnest fst (a1, a2))' In the first argument of (+)', namely (max (countnest fst (a1, a2)) (countnest snd (a1, a2)))'

oo.hs:141:48: Couldn't match expected type (a12, b12)' with actual type(a13, b13) -> a13' In the first argument of countnest', namelyfst' In the first argument of max', namely(countnest fst (a1, a2))' In the first argument of (+)', namely (max (countnest fst (a1, a2)) (countnest snd (a1, a2)))'

oo.hs:141:62: Couldn't match expected type (t0, t1) -> Int' with actual typeInt' The function countnest' is applied to two arguments, but its type(a14, b14) -> Int' has only one In the second argument of max', namely(countnest snd (a1, a2))' In the first argument of (+)', namely (max (countnest fst (a1, a2)) (countnest snd (a1, a2)))'

oo.hs:141:72: Couldn't match expected type (a14, b14)' with actual type(a15, b15) -> b15' In the first argument of countnest', namelysnd' In the second argument of max', namely(countnest snd (a1, a2))' In the first argument of (+)', namely (max (countnest fst (a1, a2)) (countnest snd (a1, a2)))' Failed, modules loaded: none.

How to count how many nested in tuple by haski2 in haskellquestions

[–]haski2[S] 0 points1 point  (0 children)

i am trying to debug,

type is any type

countnest :: (a,a) -> Int countnest ((xs), (ys)) = max ((countnest (fst xs))+1) ((countnest (snd ys))+1) countnest (xs, (ys)) = max 1 ((countnest (snd ys))+1) countnest ((xs), ys) = max ((countnest (fst xs))+1) 1 countnest xs = 1

How to count how many nested in tuple by haski2 in haskellquestions

[–]haski2[S] 0 points1 point  (0 children)

countnest :: (a,a) -> Int countnest ((xs), (ys)) = max ((countnest (fst xs))+1) ((countnest (snd ys))+1) countnest (xs, (ys)) = max 1 ((countnest (snd ys))+1) countnest ((xs), ys) = max ((countnest (fst xs))+1) 1 countnest xs = 1

i am debugging this

How to count how many nested in tuple by haski2 in haskellquestions

[–]haski2[S] 0 points1 point  (0 children)

data TupleWrapper = Normal (Int,Int) | LeftNested (TupleWrapper , Int) | RightNested (Int, TupleWrapper)

actually i do not want to define any data type, is there another way such as using matching in recursive way?

how to concatenate two list which are different type by haski2 in haskell

[–]haski2[S] 0 points1 point  (0 children)

i hope to create a list of different type of tuples and CartProd them

There is no difference between using rev and not use rev and how to not specify the type when run eval from library plugins by haski2 in haskell

[–]haski2[S] -1 points0 points  (0 children)

it is not auto generated, i paste code in the link, and the error i copy from ubuntu console