Skip to content

Instantly share code, notes, and snippets.

View 23Skidoo's full-sized avatar

Mikhail Glushenkov 23Skidoo

View GitHub Profile
@23Skidoo
23Skidoo / CYK.hs
Created September 29, 2012 04:16
The CYK algorithm in Haskell
module CYK
where
import Control.Monad
import Data.Array.IArray
import Data.Array.MArray
import Data.Array.ST
import Data.Maybe
import qualified Data.Map as M
@23Skidoo
23Skidoo / FloydWarshall.hs
Created October 17, 2012 04:24
Floyd-Warshall algorithm in Haskell
module Floyd
where
import Control.Applicative ( (<$>) )
import Control.Exception ( assert )
import Control.Monad ( forM_, when )
import Data.Array.IArray
import Data.Array.MArray
import Data.Array.ST
import Data.Maybe ( fromMaybe )
@23Skidoo
23Skidoo / InOrder.scala
Last active July 4, 2023 07:50
In-order binary tree traversal in Scala.
import scala.collection.mutable._
// Binary tree ADT.
abstract class BinaryTree
case class Node (value : Int,
left : BinaryTree, right : BinaryTree) extends BinaryTree
case class Leaf (value : Int) extends BinaryTree
// An obvious recursive solution. Can cause a stack overflow if the tree is
// very tall.
@23Skidoo
23Skidoo / remove_duplicates.ml
Created January 23, 2012 16:15
Ocaml exercise: remove duplicates from a list
let remove_elt e l =
let rec go l acc = match l with
| [] -> List.rev acc
| x::xs when e = x -> go xs acc
| x::xs -> go xs (x::acc)
in go l []
let remove_duplicates l =
let rec go l acc = match l with
| [] -> List.rev acc
@23Skidoo
23Skidoo / IntermHaskell.hs
Last active April 10, 2021 23:53
20 Intermediate Haskell Exercises
-- https://haskell.fpcomplete.com/user/DanBurton/20-intermediate-exercises
-- Originally from http://blog.tmorris.net/posts/20-intermediate-haskell-exercises/
class Fluffy f where
furry :: (a -> b) -> f a -> f b
-- Exercise 1
-- Relative Difficulty: 1
instance Fluffy [] where
furry = fmap
@23Skidoo
23Skidoo / Applicative.hs
Created August 16, 2012 20:42
Fun with Applicative, Monad and Monoidal
-- See http://blog.ezyang.com/2012/08/applicative-functors/
module Main
where
import Prelude hiding ((**))
import Control.Monad
bind :: Monad m => m a -> (a -> m b) -> m b
bind = (>>=)

[ANN] Cabal 3.2 Release

Cabal 3.2 has finally been released, including a whole host of bug fixes, new features, and other goodies. You can find the project Changelog on github if you want the rest of the changeset between this version and Cabal 3.0.

In this post, we'll go over some of the highlights in this release, as well as detail some upcomings line items and milestones for future planned work on the library.

Highlights & Bugfixes

@23Skidoo
23Skidoo / AFTER
Created February 5, 2020 22:37
Benchmarks for base64-bytestring/pull/26
benchmarking lazy/small/normal/decode
time 161.4 ns (161.1 ns .. 161.8 ns)
1.000 R² (1.000 R² .. 1.000 R²)
mean 162.2 ns (161.3 ns .. 166.0 ns)
std dev 5.041 ns (1.065 ns .. 11.34 ns)
variance introduced by outliers: 47% (moderately inflated)
benchmarking lazy/small/normal/decodeLenient
time 351.8 ns (351.3 ns .. 352.5 ns)
1.000 R² (1.000 R² .. 1.000 R²)
@23Skidoo
23Skidoo / Crawl.hs
Created October 22, 2012 11:14
Don Stewart's 2004 Obfuscated Haskell Contest entry updated to work with GHC 7.4.2
{-# LANGUAGE MagicHash #-}
module Main where
import GHC.Base
main = let l =
[106,117,115,116,32,97,32,115,105,109,112,108,101,
32,102,117,110,99,116,105,111,110,97,108,32,108,
97,110,103,117,97,103,101,0x11] :: [Int]
in
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FlexibleContexts #-}
import Control.Monad
data MobileField = MobileField String
data EmailField = EmailField String