Skip to content

Instantly share code, notes, and snippets.

View jeremyheiler's full-sized avatar

Jeremy Heiler jeremyheiler

View GitHub Profile
user> (defn foo [& {:keys [bar] :or {bar 1}}] bar)
#'user/foo
user> (foo)
1
user> (foo :baz 2)
1
user> (foo :bar 2)
2
@jeremyheiler
jeremyheiler / Main.java
Last active January 3, 2016 07:39
Read a file with one line of Java.
import java.net.URI;
import java.nio.file.Files;
import java.nio.file.Paths;
public class Main {
public static void main(String[] args) throws Exception {
System.out.println(new String(Files.readAllBytes(Paths.get("/foo.txt")), "UTF-8"));
}
}
USING: kernel math math.functions sequences ;
IN: euler1
: euler1 ( x -- y )
iota [ dup [ 3 divisor? ] [ 5 divisor? ] bi or [ drop 0 ] unless ] map-sum ;
IN: scratchpad 1 0 >
--- Data stack:
t
IN: scratchpad [ "true" ] [ "false" ] if
--- Data stack:
"true"
IN: scratchpad
As found in "Thinking Forth": http://thinking-forth.sourceforge.net/
"Simplicity is the primary measurement recommended for evaluating
alternative designs relative to reduced debugging and modification
time. Simplicity can be enhanced by dividing the system into sepa-
rate pieces in such a way that pieces can be considered, implemented,
fixed and changed with minimal consideration or effect on the other
pieces of the system."
W. P. Stevens,
: fib ( a b -- x y ) [ + ] keep swap ;
! My goal was to implement this with produce.
1 1
[ dup 4000000 < ] [ fib dup ] produce
2nip ! Remove the workspace
dup length 1 - swap remove-nth ! Remove the extra value
[ dup odd? [ drop 0 ] when ]
map-sum
StackOverflowError
java.util.regex.Pattern$GroupHead.match (Pattern.java:4556)
java.util.regex.Pattern$Loop.match (Pattern.java:4683)
java.util.regex.Pattern$GroupTail.match (Pattern.java:4615)
java.util.regex.Pattern$GroupTail.match (Pattern.java:4615)
java.util.regex.Pattern$BranchConn.match (Pattern.java:4466)
java.util.regex.Pattern$CharProperty.match (Pattern.java:3694)
java.util.regex.Pattern$Branch.match (Pattern.java:4502)
java.util.regex.Pattern$GroupHead.match (Pattern.java:4556)
java.util.regex.Pattern$Neg.match (Pattern.java:4997)
#include <stdio.h>
#include <stdlib.h>
#include <readline/readline.h>
#include <readline/history.h>
int main(int argc, char** argv)
{
puts("JL 0.0.1");
puts("Press C-c to exit\n");
#include <stdio.h>
#include <stdlib.h>
#include <readline/readline.h>
#include <readline/history.h>
int
main(int argc, char** argv)
{
puts("JL 0.0.1");
import clojure.java.api.Clojure;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
public class NreplContextListener implements ServletContextListener {
private Object server;
public NreplContextListener() {
Clojure.var("clojure.core", "require").invoke(Clojure.read("clojure.tools.nrepl.server"));