Guest User

Untitled

a guest
Aug 17th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. data List a = Cons a (List a)
  2. | Nil
  3. defining Show
  4.  
  5. *Main> Cons 0 Nil
  6. Cons 0 Nil
  7. *Main> Cons 1 it
  8. Cons 1 (Cons 0 Nil)
  9. *Main>
  10.  
  11. List a
  12.  
  13. List a
  14.  
  15. List a
  16.  
  17. List a
  18.  
  19. List a
  20.  
  21. List a
  22.  
  23. class List<A>
  24. {
  25. }
  26.  
  27. class Nil<A> : List<A>
  28. {
  29. public Nil() {}
  30. }
  31.  
  32. class Cons<A> : List<A>
  33. {
  34. public A Head;
  35. public List<A> Tail;
  36.  
  37. public Cons(A head, List<A> tail)
  38. {
  39. this.Head = head;
  40. this.Tail = tail;
  41. }
  42. }
  43.  
  44. Cons a (List a)
  45.  
  46. Cons { headL :: a, tailL :: List a }
  47.  
  48. Cons a (List a)
Add Comment
Please, Sign In to add comment