Skip to content

Instantly share code, notes, and snippets.

Arity and dispatch

  • functions have a single, known arity

Given a function f, with arity 3 (lambda (a b c) ...), application can be performed in three ways:

partial application: (f 1)

  • return curried function with arity 2

exact application: (f 1 2 3)

$ time ./truffleshen '(+ 1 2)'
Loading toplevel.kl
Loading core.kl
Loading sys.kl
Loading sequent.kl
Loading yacc.kl
Loading reader.kl
Loading prolog.kl
Loading track.kl
Loading load.kl
[20:39:21][ragnardahlen@STOLTM3227:~/projects/github/graalvm/graal-core]
$ mx build
Compiling com.oracle.mxtool.compilerserver with javac... [/Users/ragnardahlen/projects/github/graalvm/mx/mxbuild/java/com.oracle.mxtool.compilerserver/bin/com/oracle/mxtool/compilerserver/CompilerDaemon.class does not exist]
warning: [options] bootstrap class path not set in conjunction with -source 1.7
1 warning
Compiling com.oracle.truffle.api.source with javac-daemon... [/Users/ragnardahlen/projects/github/graalvm/truffle/mxbuild/truffle/com.oracle.truffle.api.source/bin/com/oracle/truffle/api/source/Content.class does not exist]
Compiling org.graalvm.compiler.nodeinfo with javac-daemon... [/Users/ragnardahlen/projects/github/graalvm/graal-core/mxbuild/graal/org.graalvm.compiler.nodeinfo/bin/org/graalvm/compiler/nodeinfo/InputType.class does not exist]
Compiling org.graalvm.util with javac-daemon... [/Users/ragnardahlen/projects/github/graalvm/graal-core/mxbuild/graal/org.graalvm.util/bin/org/graalvm/util/EconomicMap.class
11:22:29.363557 open("/dev/console", O_WRONLY|O_NOCTTY|O_CLOEXEC) = 30 <0.000029>
11:22:29.363613 ioctl(30, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, {B38400 opost isig -icanon -echo ...}) = 0 <0.000021>
11:22:29.363664 writev(30, [{"[71658.329457] ", 15}, {"docker", 6}, {"[804]: ", 7}, {"{\"@timestamp\":\"2016-03-08T11:22:29.361+00:00\",\"@version\":1,\"logger_name\":\"nocrm-bigquery-transform.core\",\"thread_name\":\"main\",\"level_name\":\"INFO\",\"message\":\"inserted batch with 1000 rows\"}", 188}, {"\n", 1}], 5) = 217 <0.003830>
11:22:29.367539 close(30) = 0 <0.000021>
@ragnard
ragnard / dsl.rb
Created December 2, 2015 12:28
terrafied
# additions
def resource_names
ret = []
for type in @output["resource"].keys
for id in @output["resource"][type].keys
ret << "#{type}.#{id}"
end
end
ret
\d+ clickouts
Table "public.clickouts"
Column | Type | Modifiers | Storage | Stats target | Description
------------+-----------------------------+-----------+----------+--------------+-------------
click_ref | character varying(36) | not null | extended | |
click_date | timestamp without time zone | not null | plain | |
deal_id | character varying(40) | not null | extended | |
raw_data | jsonb | not null | extended | |
user_agent | jsonb | | extended | |
Indexes:
.classpath: project.clj
lein classpath \
| tr ':' '\n' \
| sed '/\.jar/!d' \
> .classpath
repl: .classpath
@java -cp $(shell cat .classpath | tr '\n' ':') clojure.main -i nrepl.clj -r
.PHONY: repl
(require '[clj-kafka.core :refer [with-resource]]
'[clj-kafka.consumer.zk :as kafka.consumer])
(defn deserialize-message
[message]
message)
(defn production-traffic?
[event]
true)
@ragnard
ragnard / upstart
Created May 25, 2015 21:20
/etc/logrotate.d/upstart
/var/log/upstart/*.log {
daily
missingok
rotate 7
compress
notifempty
nocreate
}
// write literal true
ByteArrayOutputStream bs1 = new ByteArrayOutputStream();
(new ObjectOutputStream(bs1)).writeObject(true);
// write Boolean.TRUE
ByteArrayOutputStream bs2 = new ByteArrayOutputStream();
(new ObjectOutputStream(bs2)).writeObject(Boolean.TRUE);
// did we write same bytes? yes.
System.out.println(Arrays.equals(bs1.toByteArray(), bs2.toByteArray())); // true