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
(* | |
* Hofstadter sequences | |
* https://en.wikipedia.org/wiki/Hofstadter_sequence | |
*) | |
signature QUEUE = | |
sig | |
type 'a queue = 'a list * 'a list | |
val empty: 'a queue | |
val enqueue: 'a -> 'a queue -> 'a queue |
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
def fib(): | |
a, b = 0, 1 | |
while True: | |
yield a | |
a, b = b, a + b |
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
import random | |
import curses | |
import sys | |
import time | |
class Board(object): | |
WINNING_COMBOS = ( | |
(0, 1, 2), | |
(3, 4, 5), |
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
fun help () = print "Run me as: \n\tpoly -q --use foo.sml --eval 'val _ = main ()'\n" | |
fun main () = (TextIO.output (TextIO.stdErr, "ZOMG!"); OS.Process.exit OS.Process.success) |
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
// count occurrences of the same combination of characters in an array of strings | |
// example: | |
// > console.log(count(['ab', 'ba'])) | |
// [2] | |
const xs = [ 'aba', 'aab', 'ccc', 'ddc', 'dcd', 'baa', 'dds', 'sdd', 'dcd', 'xyz' ]; | |
const count = xs => { | |
const map = xs.reduce((acc, x) => { | |
const key = Array.from(new Set(x)).sort().join(''); | |
return { |
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 main | |
import ( | |
"fmt" | |
"sort" | |
"golang.org/x/tour/tree" | |
) | |
// Walk walks the tree t sending all values |
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
{ | |
do { | |
if (!this.isQuotePublished()) { | |
<div> | |
<Dialog ref="modalDeleteQuoteDraft" type="modal"> | |
<DialogOverlay> | |
<DialogHeader> | |
<DialogTitle>{ t('QUOTE_DRAFT_DELETE') }</DialogTitle> | |
</DialogHeader> | |
<p style={ { padding: 20 } }> |
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
def max_difference(xs): | |
max = min = xs[0] | |
d = -1 | |
for x in xs[1:]: | |
if min > x: | |
min = max = x | |
continue | |
if x > max: | |
max = x | |
if max - min > d: |
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
fun fizzbuzz' n = | |
case (n mod 5 = 0, n mod 3 = 0) of | |
(true, true) => "FizzBuzz" | |
| (true, false) => "Buzz" | |
| (false, true) => "Fizz" | |
| _ => Int.toString n | |
fun fizzbuzz n = | |
let | |
fun loop m = |
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
(|>) :: a -> (a -> b) -> b | |
x |> f = f x | |
[1..6] |> sum | |
inc = (+) 1 | |
[1..5] |> map inc |> sum |