Skip to content

Instantly share code, notes, and snippets.

@mjgpy3
mjgpy3 / Day1.hs
Created January 31, 2024 14:52
Advent of Code 2023 first 3 days
module Year2023.Day1 (
parts,
) where
import Adlude
import Data.Char (isDigit)
import Data.List (tails)
import qualified Data.Text as T
numbers =
@mjgpy3
mjgpy3 / CalcVScheme.hs
Created October 5, 2022 20:00
calc v scheme in Haskell
module CalcVScheme where
import Prelude hiding (lookup)
data Term
= Var Var
| Lambda Var Term
| Apply Term Term
| Closure Env Var Term
deriving (Eq, Show)
@mjgpy3
mjgpy3 / conway.el
Created June 20, 2022 03:51
conway.el
(defun conway-current-buffer (alive-char)
(interactive "cAlive-charater: ")
(defun key (x y)
(concat (number-to-string x) "-" (number-to-string y)))
(defun pair-to-key (p)
(concat (number-to-string (car p)) "-" (number-to-string (cadr p))))
(defun neighbors (x y)
@mjgpy3
mjgpy3 / Lib.hs
Created June 5, 2022 13:39
SKI Combinators
module Lib
( Ski(..)
, eval
, someFunc
) where
import Test.QuickCheck
data Ski
= I
@mjgpy3
mjgpy3 / learn_haskell_by_building.md
Last active November 21, 2023 19:54
Learn Haskell by Building (Assignment)

Learn Haskell by Building

Congratulations and welcome to the new VC-funded startup Kewl-Word-Divination.ai! We may not have a working product yet but that's where you come in! (Don't worry we've got a few months of runway).

Since we're following a new methodology -- the Scant Agile Framework -- we'll be building our product out iteratively (the way the Mona Lisa was painted).

v0.01 - kwd CLI

@mjgpy3
mjgpy3 / Lib.hs
Last active May 19, 2022 11:09
maybe-haskell-homework-bad-functor
module Lib
( someFunc
, DeciderOutcome(..)
, badFmap1
, badFmap2
, badFmap3
) where
data DeciderOutcome a
= Outcome a
@mjgpy3
mjgpy3 / maybe-haskell-homework.md
Last active May 12, 2022 15:14
Maybe Haskell Homework

Exercise: Evaluating with <$> and <*>

Given the example from the book:

User
<$> getParam "name" params
<*> getParam "email" params

Walk through the steps of evaluation of this code, given the following cases

@mjgpy3
mjgpy3 / Lib.hs
Created April 26, 2022 13:03
Incomplete Sudoku Solver
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE LambdaCase #-}
module Lib
( solve
) where
import Control.Arrow ( (&&&) )
import Data.Char ( isNumber )
import Data.Foldable ( for_ )
@mjgpy3
mjgpy3 / Problem96.hs
Created April 26, 2022 13:01
SBV Sudoku Solver
module Problem96
( answer
) where
import Data.Foldable (for_)
import Data.List (transpose)
import qualified Data.Map.Strict as M
import Data.SBV
import Problem96Input (grids)
@mjgpy3
mjgpy3 / MonadicParsingInHaskell.hs
Created February 1, 2022 18:30
Monad Parsing in Haskell Type-Along
{-# LANGUAGE LambdaCase #-}
module Lib
( someFunc
) where
import Control.Applicative (Alternative (empty, (<|>)))
import Control.Monad (MonadPlus (..))
import Data.Bifunctor (first)
import Data.Char (isDigit, isSpace, ord)