Skip to content

Instantly share code, notes, and snippets.

View snahor's full-sized avatar

Hans Roman snahor

  • Wakanda
View GitHub Profile
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)
// 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 {
@snahor
snahor / concurrency-8.go
Created May 2, 2017 18:17
A tour of Go
package main
import (
"fmt"
"sort"
"golang.org/x/tour/tree"
)
// Walk walks the tree t sending all values
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:
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 =
@snahor
snahor / derp.hs
Last active October 18, 2016 05:23
F#'s pipe forward in Haskell
(|>) :: a -> (a -> b) -> b
x |> f = f x
[1..6] |> sum
inc = (+) 1
[1..5] |> map inc |> sum
const findLastRowWithValue = (sheet) => {
const { decode_cell } = XLSX.utils;
const { r } = decode_cell(sheet['!ref'].split(':')[1]);
const isEmpty = (x) => sheet[`A${ x }`].v === undefined;
let start = 1;
let end = r + 1;
let pivot = Math.round((end - start) / 2);
if (pivot === 0) {
{
do {
if (!this.isQuotePublished()) {
<div>
<Dialog ref="modalDeleteQuoteDraft" type="modal">
<DialogOverlay>
<DialogHeader>
<DialogTitle>{ t('QUOTE_DRAFT_DELETE') }</DialogTitle>
</DialogHeader>
<p style={ { padding: 20 } }>
Function nameList(ParamArray xs() As Variant) As String
For i = LBound(xs) To UBound(xs)
For Each x In xs(i).Cells
If x.value <> "" Then
If nameList <> "" Then
nameList = nameList & ", "
End If
nameList = nameList & x.value
End If
Next x
@snahor
snahor / retry.js
Last active September 28, 2016 07:34
function* fib() {
let a = 0;
let b = 1;
while (true) {
[a, b] = [b, a + b];
yield a;
}
}
const sleep = async (n) => await (new Promise(r => setTimeout(r, n)));