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
(defmacro letp [expr bindings & body] | |
(let [parted | |
(partition 3 bindings) | |
true-bindings | |
(vec (apply concat | |
(map #(take 2 %) parted))) | |
false-bindings | |
(vec (apply concat | |
(map #(list (first %) (last %)) parted)))] |
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 dynamic-record [base-name field-names & init-values] | |
(let [klass (eval `(defrecord ~(gensym base-name) ~(vec field-names))) | |
ctor (first (.getConstructors klass)) | |
vals (take (count field-names) | |
(concat init-values (repeat nil)))] | |
(.newInstance ctor (into-array Object vals)))) | |
(dynamic-record "MyRecord" '(foo bar) :foo) | |
;; -> #:user.MyRecord14544{:foo :foo, :bar 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
(ns fxtrial.core | |
(:import javax.script.ScriptEngineManager | |
com.sun.javafx.api.JavaFXScriptEngine)) | |
(def engine (.getEngineByName (ScriptEngineManager.) "javafx")) | |
(defn wrap-fxfn [fxfn] | |
(let [invoke | |
(first (filter #(= (.getName %) "invoke") |
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 org.jfxtras.lang.XBind; | |
import javafx.stage.*; | |
import javafx.scene.*; | |
import javafx.scene.layout.HBox; | |
import javafx.scene.control.*; | |
function run():Void { | |
try { |
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
;; the project file | |
(defproject lein-javafx "0.1.0" | |
:dependencies [[javafxc "1.3.1"]] | |
:hooks [leiningen.hooks.lein-javafx-hooks]) | |
;; the javafxc task file | |
(ns leiningen.javafxc |
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
module A where | |
import Data.HList.CommonMain | |
data A = A deriving (Show) | |
ls = hCons "hi" $ hCons A $ hNil | |
upls = hUpdateAtType "bye" ls |
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 i: int64 = 0 | |
let j: float64 = 1.1 | |
proc g(x: distinct SomeNumber = 1, y: distinct SomeNumber = 1.1) = discard | |
g(i,j) # OK | |
g(j,i) # Error | |
# I have tried other combinations without use of distinct. Not sure | |
# why the compiler complains about this, seems it should be ok? |
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/bash | |
DEFAULT_TEMPLATE="sbt/scala-seed.g8" | |
function err { | |
echo "error: $1, exiting." | |
exit 1 | |
} | |
if [[ -z "$1" ]] |
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
use std::sync::atomic::{AtomicUsize, Ordering}; | |
use std::sync::Arc; | |
pub enum RunFlagState { | |
Running = 0, | |
Paused = 1, | |
Cancelled = 2, | |
} | |
// TODO: is there some mechanism to automate this (nightly)? |