Difference between revisions of "FP Laboratory 10"

From Marek Běhálek Wiki
Jump to navigation Jump to search
(Created page with "== Abstract data types == * Create an abstract data type <code>Stack</code> with following functions: <syntaxhighlight lang="Haskell"> push :: a -> Stack a -> Stack a pop ::...")
 
Line 7: Line 7:
 
top :: Stack a -> a
 
top :: Stack a -> a
 
isEmpty :: Stack a ->Bool
 
isEmpty :: Stack a ->Bool
 +
</syntaxhighlight>
 +
* Create an abstract data type <code>Queue</code> with following functions:
 +
<syntaxhighlight lang="Haskell">
 +
isEmpty :: Queue a -> Bool
 +
addQ :: a -> Queue a -> Queue a
 +
remQ :: Queue q -> (a, Queue a)
 
</syntaxhighlight>
 
</syntaxhighlight>

Revision as of 12:05, 18 September 2019

Abstract data types

  • Create an abstract data type Stack with following functions:
push :: a -> Stack a -> Stack a
pop :: Stack a -> Stack a
top :: Stack a -> a
isEmpty :: Stack a ->Bool
  • Create an abstract data type Queue with following functions:
isEmpty :: Queue a -> Bool
addQ :: a -> Queue a -> Queue a
remQ :: Queue q -> (a, Queue a)