This file contains 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
#!/usr/bin/env runhaskell | |
{-# LANGUAGE OverloadedStrings #-} | |
import Turtle | |
main :: IO () | |
main = do | |
stdout (runWatch $ findSrc) |
This file contains 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
function chjava() { | |
if [ $# -ne 0 ]; then | |
removeFromPath '/System/Library/Frameworks/JavaVM.framework/Home/bin' | |
if [ -n "${JAVA_HOME+x}" ]; then | |
removeFromPath $JAVA_HOME | |
fi | |
export JAVA_HOME=`/usr/libexec/java_home -v $@` | |
export PATH=$JAVA_HOME/bin:$PATH | |
fi | |
} |
This file contains 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
sealed trait Opt[+A] { | |
def flatMap[T](f: A => Opt[T]): Opt[T] = | |
fold[Opt[T]](Nothing)(f) | |
def map[T](f: A => T): Opt[T] = | |
fold[Opt[T]](Nothing)(a => Something(f(a))) | |
def fold[B](g: => B)(f: A => B): B = | |
this match { | |
case Something(a) => f(a) |
This file contains 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
# An equilibrium index of a sequence is an index into the sequence | |
# such that the sum of elements at lower indices is equal to the | |
# sum of elements at higher indices. | |
def eq_indices(arr) | |
left, right = 0, arr.inject(0, :+) | |
result = [] | |
arr.each_with_index do |el, i| | |
right -= el | |
result << i if right == left |
NewerOlder