Skip to content

Instantly share code, notes, and snippets.

View cataska's full-sized avatar
😱
🥺😢😭

Wen-Chun Lin cataska

😱
🥺😢😭
  • Taipei, Taiwan
View GitHub Profile
(defmacro infix
[infixed]
(list (second infixed)
(first infixed)
(last infixed)))
(infix (1 + 2))
; => 3
(defmacro unless [conditional & body]
`(if (not ~conditional)
(do ~@body)))
;; => #'unless
(unless false "Hello JCConf")
;; => "Hello JCConf
(def numbers [1 2 3])
;; => #'numbers
(conj numbers 4)
;; => [1 2 3 4]
numbers
;; => [1 2 3]
;; Lists
'(1 2 3 4 5)
'(:foo :bar 2)
;; Vectors
[:foo :bar]
[3 4 5 nil]
;; Maps
{:foo "bar", :baz 2}
;; Numbers
23
-100
1.7
-2
33e8
;; Keywords
:foobar
:2
(inc 1)
;; => 2
(+ 1 2 3 4)
;; => 10
((fn [x] (* x x)) 5)
;; ==> 25
(def square (fn [x] (* x x)))
#include <iostream>
#include <cmath>
#include <chrono>
uint32_t num_calls = 0; // to fool optimizer
namespace constants
{
constexpr const auto time_step = 0.01;
constexpr const auto num_samples = 100000;
#include <iostream>
#include <cstdlib>
#include <stdio.h>
#include <math.h>
#include <array>
using namespace std;
int main()
{
double dt = 0.01;
(inc 1)
(map inc [1 2 3])
(.getElementById js/document "app")
(defn average [a b]
(/ (+ a b) 2.0))
;; Numbers
23
-100
1.7
-2
33e8
;; Keywords
:foobar
:2