fork download
  1. import Control.Applicative
  2.  
  3. data L=S Int|V{v::[L]}
  4. d(V z)=1+maximum(d<$>S 0:z);d _=0
  5. S x!S y=S$x+y
  6. (x:a)#(y:b)=x!y:a#b;a#b=a++b
  7. x!y|d x<d y=V$(x!)<$>v y|d x>d y=y!x|1<2=V$v x#v y
  8.  
  9. instance Show L where
  10. show (S x) = show x
  11. show (V x) = show x
  12.  
  13. lArg = V [S 1, S 2, S 3, V []]
  14. rArg = V [S 10, V [S 20]]
  15. main = print $ lArg ! rArg
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
[1 of 1] Compiling Main             ( prog.hs, prog.o )

prog.hs:7:2:
    Multiple declarations of `!'
    Declared at: prog.hs:5:4
                 prog.hs:7:2
stdout
Standard output is empty