This file contains hidden or 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
;; lambda expression do not have any assignments | |
;; so we will use the form where there is not lambda expressions | |
((lambda () | |
(define (adder n) (+ n 1)) | |
(define (mult3 n) (* n 3)) | |
(mult3 (adder 10)) | |
)) | |
;; create make-adder and compose using higher-order functions |
This file contains hidden or 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
stack unpack $package | |
cd $package-$version | |
stack init --resolver nightly | |
stack build --resolver nightly --haddock --test --bench --no-run-benchmarks |
This file contains hidden or 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
from openpyxl.styles import Alignment | |
def format_data(index, col_name): | |
alignment = Alignment(horizontal=’right’) | |
if col_name == ‘salary’: | |
return dict( | |
alignment=alignment, | |
number_format='$0.00') |
This file contains hidden or 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
;;; package --- Something here | |
;;; Commentary: | |
;;; Code: | |
(defun get-line-no () | |
"Returns line no of first argument" | |
(interactive) | |
(let* (lineno) | |
(save-excursion | |
(start-of-paragraph-text) |
This file contains hidden or 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
-- continuation calling style of functions | |
f :: forall a. Integral a => a -> (a -> a) -> a -> a | |
f y fun x = if x == y then x * x else fun x | |
f_base :: forall a. Num a => a -> a |
This file contains hidden or 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 KindSignatures #-} | |
{-# LANGUAGE RankNTypes #-} | |
{-# LANGUAGE OverloadedStrings #-} | |
import Control.Concurrent.MVar |
This file contains hidden or 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
-- sequence a state monad | |
import Control.Monad.Trans.State | |
-- Example 1 | |
let y = do { z <- get; let a = (Prelude.last z) + 1 in put (z Prelude.++ [a]);return $ (Prelude.last z) + 1} :: State [Int] Int | |
runState (sequenceA [y,y,y]) $ [1] | |
-- Example: 2 | |
type X = State (M.Map String Int) Int | |
let y s s1 = do { z <- get; let a = z M.! s + 1 in put (M.insert s1 a z) ; let a = z M.! s + 1 in return $ a } :: X |
This file contains hidden or 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
-- Adapted from http://chrisdone.com/posts/data-typeable | |
recordShow :: Data a => a -> ShowS | |
recordShow = render `extQ` (shows :: String -> ShowS) where | |
render t | |
| isTuple = drop 1 . tupleSlots | |
| |
This file contains hidden or 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
import unittest | |
def foo(x, y, z): | |
return (x != y and x != z or x and z) | |
def get_test_args(): | |
x = y = z = [True, False] | |
from itertools import product, repeat | |
input_args = list(product(x, y, z)) | |
expected_args = [ |
This file contains hidden or 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
import pyodbc | |
# This will be the query to run | |
sql = 'SELECT * FROM AAF_IS_USER' | |
# conn_str = Here repace USER with treussard and YOUR_PASSWORD with the actual password |