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; |
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
### 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
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
(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
interface I<TP> { | |
fun TP.func() | |
} | |
class Dummy | |
class Implementer : I<Dummy> { | |
override fun Dummy.func() { | |
println(this) | |
} |
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
(defn index-of-safe | |
"Return index of value (string or char) in s, optionally searching | |
forward from from-index. Return nil if value not found. | |
Works around https://bugs.openjdk.java.net/browse/JDK-8027640 | |
so the returned index is always greater equal to from-index. | |
This also works around JavaScript's similar behavior." | |
[s value from-index] | |
(if (< (count s) from-index) | |
nil | |
(clojure.string/index-of s value from-index))) |
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
;; heavily inspired by Mariano Guerra | |
;; http://marianoguerra.org/posts/download-frontend-generated-data-to-a-file-with-clojurescript.html | |
(defn download-blob [file-name blob] | |
(let [object-url (js/URL.createObjectURL blob) | |
anchor-element | |
(doto (js/document.createElement "a") | |
(-> .-href (set! object-url)) | |
(-> .-download (set! file-name)))] | |
(.appendChild (.-body js/document) anchor-element) | |
(.click anchor-element) |
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
;; some surprises found while learning Clojure | |
;; min is for numbers | |
(min #inst "2018" #inst "2019") ; Execution error (ClassCastException) at clojure-test.core/eval8469 (form-init524028722621051551.clj:2589) . | |
; java.util.Date cannot be cast to java.lang.Number | |
;; macros are not values | |
(apply or (list false true)) ; Syntax error compiling at (Untitled-1:2:1). | |
; Can't take value of a macro: #'clojure.core/or |
OlderNewer