Skip to content

Instantly share code, notes, and snippets.

@pseudometric
Last active April 24, 2021 03:55
Show Gist options
  • Save pseudometric/485f3c9a5d96a197c314a86ebf102320 to your computer and use it in GitHub Desktop.
Save pseudometric/485f3c9a5d96a197c314a86ebf102320 to your computer and use it in GitHub Desktop.
Lisa’s Haskell snippet
#!/usr/bin/env stack
-- stack --resolver lts-17.9 script
module Main where
import Data.List
numbers = [2..9]
fruits = ["apple", "banana", "eggplant", "cherry", "kiwi", "tomato"]
vegetables = ["carrot", "tomato", "celery", "eggplant", "spinach"]
squares = map (^2) numbers
stupidfruits = intersect fruits vegetables
realvegetables = vegetables \\ fruits
main = do
putStrLn $ " squares: " <> show numbers
putStrLn $ " stupidfruits: " <> show stupidfruits
putStrLn $ "realvegetables: " <> show realvegetables
@pseudometric
Copy link
Author

$ ./fruits.hs 
       squares: [2,3,4,5,6,7,8,9]
  stupidfruits: ["eggplant","tomato"]
realvegetables: ["carrot","celery","spinach"]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment