so defined a type called term which is a coffecient and degree of x. int a int b.
I want to write a method/methods in haskell to sort them and combine ones with same degree. I think I need to combine somehow, and then use sortby method? I'm just learning haskell, but I now java and c# pretty well and I'm having a hard term converting to functional thinking.
its of type [(Int a Int b)] and if b1< b2 put tuple 1 before tuple2, else if = combine by adding a1 to a2, else place 2 before 1
I tried something like this based on an example but its pretty random:
sortby xxx [(Term a b) : (Term c d) : xs]
xxx | b < d = LG
| b > d = RG
I want to write a method/methods in haskell to sort them and combine ones with same degree. I think I need to combine somehow, and then use sortby method? I'm just learning haskell, but I now java and c# pretty well and I'm having a hard term converting to functional thinking.
its of type [(Int a Int b)] and if b1< b2 put tuple 1 before tuple2, else if = combine by adding a1 to a2, else place 2 before 1
I tried something like this based on an example but its pretty random:
sortby xxx [(Term a b) : (Term c d) : xs]
xxx | b < d = LG
| b > d = RG
Last edited: