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
(ns util | |
(:require [clojure.java.io :as io]) | |
(:import org.apache.commons.io.input.BOMInputStream | |
org.apache.commons.io.ByteOrderMark)) | |
(defn bom-reader | |
"Returns a BOM contextual reader with the proper encoding set (= BOM), defaults to UTF-8" | |
[input-stream] | |
(let [bom-array | |
(into-array [ByteOrderMark/UTF_16LE |
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
open System | |
open System.Collections.Generic | |
let rl = Console.ReadLine | |
let splsp (s:string) = s.Split([|' '|], StringSplitOptions.RemoveEmptyEntries) | |
let getTwo (a:_[]) = a.[0], a.[1] | |
let getThree (a:_[]) = a.[0], a.[1], a.[2] | |
let callN n action = seq { for i = 1 to n do yield action()} |> Seq.toArray | |
let iterrl f = | |
let rec loop () = | |
let l = rl() |
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
### Keybase proof | |
I hereby claim: | |
* I am zoren on github. | |
* I am zoren (https://keybase.io/zoren) on keybase. | |
* I have a public key whose fingerprint is 6CB1 901B E1F1 877D E4C6 353A 55FD 41CE 594E 9B0C | |
To claim this, I am signing this object: |
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
// Created by Søren Sjørup on 16/04/16. | |
// Copyright © 2016 Søren Sjørup. All rights reserved. | |
import Foundation | |
indirect enum Exp{ | |
case C(Int) | |
case Bin(Exp, String, Exp) | |
} |
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
let rec f _ = | |
let _ = myignore 1 | |
myignore () // not ok, myignore expects int as argument type | |
and myignore _ = () | |
let rec myignore _ = () | |
and f _ = | |
let _ = myignore 1 | |
myignore () // ok, myignore accepts any type as argument type |
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
private static Array DownCastArray<TE>( TE[] ar, Type elementType ) { | |
Array castDown = Array.CreateInstance( elementType, ar.Length ); | |
for ( int i = 0; i < ar.Length; i++ ) { | |
object value = ar[i]; | |
if ( !elementType.IsInstanceOfType( value ) ) { | |
throw new ArgumentException( "df" ); | |
} | |
castDown.SetValue( value, i ); | |
} | |
return castDown; |
NewerOlder