This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE InstanceSigs #-} | |
import Control.Applicative | |
import Control.Monad | |
import Control.Monad.Trans.Writer | |
-- Here is a direct style pythagoras function | |
-- There are two noticeable things in the function body. | |
-- 1. Evaluation order of x * x vs y * y is unknown/implicit. | |
-- 2. We don't care what happens to the final value (implicit continuation). | |
pyth :: (Floating a) => a -> a -> a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main where | |
import Data.Char | |
import Data.Map | |
-- Shunting - Yard algorithm for Reverse Polish Notation | |
data Token = Number Int | ParenOpen | ParenClose | |
| AddOp | MulOp | DivOp | SubOp | |
deriving (Show, Eq) |
OlderNewer