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
( grep.tal ) | |
( ) | |
( by d_m ) | |
( print a character to STDOUT ) | |
%emit { #18 DEO } | |
( the first argument to grep is the regex ) | |
( arguments are passed on STDIN, so we just ) | |
( assume the first "line" is the argument ) |
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
;; tal-mode.el | |
;; | |
;; by d_m | |
;; use rx for regular expressions | |
(require 'rx) | |
;; set up a mode hook (currently unused) | |
(defvar tal-mode-hook nil) |
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
( rng.tal ) | |
( simple 16-bit xorshift RNG ) | |
( based on http://b2d-f9r.blogspot.com/2010/08/16-bit-xorshift-rng-now-with-more.html ) | |
%<<5 { #50 SFT2 } | |
%>>1 { #01 SFT2 } | |
%>>3 { #03 SFT2 } | |
%RTN { JMP2r } | |
%EMIT { #18 DEO } | |
%DIGIT { #00 SWP ;digits ADD2 LDA EMIT } |
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
package cats.parse | |
package examples | |
import cats.implicits._ | |
import Parser.{char, charWhere, charsWhile, string1} | |
object Csv { | |
def mkString(p: Parser1[Char]): Parser[String] = |
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
package demo | |
import cats.{Applicative, Functor, Id, Semigroupal, Traverse} | |
import cats.arrow.FunctionK | |
/** | |
* Type-lifting operation to replace the wildcard type (i.e. _). | |
* | |
* In some cases we end up with code like: List[Option[_]]. This is | |
* fine unless you later need to write code in terms of a particular |
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 python | |
# | |
# by Erik Osheim | |
# | |
# STEPS TO USE | |
# | |
# 0. install deps | |
# - pip install requests | |
# | |
# 1. generate personal access token |
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
COLLECTION 0 1 5 10 50 100 500 1000 | |
Array[Int] 16 24 40 56 216 416 2016 4016 | |
immutable.BitSet 24 24 24 24 24 32 96 160 | |
immutable.IntMap[Int] 16 40 328 688 3568 7168 35968 71968 | |
immutable.List[Int] 16 56 216 416 2016 4016 20016 40016 | |
immutable.Map[Int,Int] 16 40 304 720 4856 9680 53504 111760 | |
immutable.Queue[Int] 40 80 240 440 2040 4040 20040 40040 | |
immutable.Set[Int] 16 32 264 480 3016 5840 27696 57952 | |
immutable.SortedMap[Int,Int] 40 88 280 520 2440 4840 30008 62008 | |
immutable.SortedSet[Int] 40 104 296 536 2456 |
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
#!/bin/sh | |
# | |
# simple streaming from the command line: | |
# | |
# ./cast.sh send *.mp3 # stream some files | |
# | |
# ./cast.sh recv # listen to the stream | |
# | |
# currently hardcodes localhost port 9999. | |
# |
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
package quantity | |
// like Nat, but for integers | |
trait Z | |
// Pos means positive-or-zero, and Neg means negative-or-zero | |
trait Pos extends Z { type P <: Pos } | |
trait Neg extends Z { type N <: Neg } | |
class Zero extends Pos with Neg { type N = Zero } |
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
package cats.collections | |
sealed abstract class LogicalBitSet { lhs => | |
import LogicalBitSet.{Absent, Present} | |
def apply(n: Int): Boolean = | |
this match { | |
case Present(bits) => bits(n) | |
case Absent(bits) => !bits(n) |