Install homebrew then run brew install swi-prolog
.
You can now run the Prolog shell from the command line with swipl
.
Important: do not install from the official website, you will get crashes.
Install homebrew then run brew install swi-prolog
.
You can now run the Prolog shell from the command line with swipl
.
Important: do not install from the official website, you will get crashes.
### Keybase proof | |
I hereby claim: | |
* I am norswap on github. | |
* I am norswap (https://keybase.io/norswap) on keybase. | |
* I have a public key whose fingerprint is CB7E 4E0F F8C0 2860 6A62 55F2 A7E2 9E43 45FB 1D8E | |
To claim this, I am signing this object: |
inline fun <T, U> (() -> T?).map (crossinline f: (T) -> U): (() -> U?) | |
{ | |
return { this()?.let(f) } | |
} | |
inline fun <T> (() -> T?).filter (crossinline pred: (T) -> Boolean): (() -> T?) | |
{ | |
return { | |
var out = this() | |
while (out != null && !pred(out)) out = this() |
In the VM properties, make two connections: a "NAT" for regular internet connectivity, and a "host-only" for ssh connectivity between host and guest with a predictable IP. For this to work, both a NAT adapter and a host-only adapter have to be created in the host via the VirtualBox global preferences.
// Basic setup | |
interface Exp | |
data class Lit(val x: Int): Exp | |
data class Add(val x: Exp, val y: Exp): Exp | |
val exp0 = Add(Lit(42), Lit(0x52)) | |
// Adding a print operation |
// Basic setup | |
interface Exp | |
data class Lit(val x: Int): Exp | |
data class Add(val x: Exp, val y: Exp): Exp | |
interface IntAlg<A> | |
{ | |
fun lit(x: Int): A | |
fun add(x: A, y: A): A |
package util; | |
import java.lang.reflect.InvocationTargetException; | |
import java.lang.reflect.Method; | |
/** | |
* This class implements multiple dispatch (aka multimethods) using reflection. | |
* The idea is to choose the method based not only on the runtime type of the | |
* receiver, but also on the runtime type of the arguments. Normally Java | |
* selects amongst overloaded alternatives using the static type. |
# Jaffar, the Evil Advisor Library | |
# | |
# This is a simple experiment in Ruby metaprogmming, to see how to implement | |
# a lisp-style advising construct. Advising is basically augmenting existing | |
# functions with your own code. See the exemple below. | |
# | |
# Advising is very much related to context-oriented programming. I fortunately | |
# have no use for either an advising or context-oriented programming right now | |
# and this is why I did not expand upon this simple implementation. | |
# |