-- ---
-- jupyter:
--   jupytext:
--     text_representation:
--       extension: .hs
--       format_name: light
--       format_version: '1.5'
--       jupytext_version: 1.14.4
--   kernelspec:
--     display_name: Haskell
--     language: haskell
--     name: haskell
-- ---

square x = x ** 2

square 10

-- # Modules

-- Loading a function from a file `baby.hs` which contains a function `doubleMe`

:l baby

doubleMe 4

doubleMe 3.14

doubleMe pi

-- # Creating higher level functions

doubleSum x y = doubleMe x + doubleMe y

doubleSum 10 20

doubleSum 1 2 + doubleSum 10 12

-- * Functions in Haskell don't have to be in any particular order
-- * Functions can be redefined

-- +
doubleMe x = x * 3

doubleSum x y = doubleMe x + doubleMe y
-- -

doubleSum 10 20

:l baby.hs

-- # If-else statement

doubleSmallNumber x = if x > 100
                         then x
                         else x * 2

-- * else part is mandatory in Haskell
-- * if-else statement is an expression as it always returns something

doubleSmallNumber 101

doubleSmallNumber 99

doubleSmallNumber' x = (if x > 100 then x else x * 2) + 1

doubleSmallNumber' 101

-- Apostrophe `'` is a valid character in a function name. Usually denoted to write a strict (non-lazy) version or a modified version.

conanO'Brien = "It's a-me, Conan O'Brien!"   

-- * This is also a function with no input parameters
-- * The convention is to use camelCase, although not strictly
-- * Functions can't begin with uppercase

snake_case = "Harrrrry pott-ahhhhh"

StarcoderdataJupyterScriptsDedupFiltered