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 [[fst & rst] (parse "(+ 1 1)")] | |
[fst rst]) | |
--> [:+ (1.0 1.0)] |
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
(async | |
(for [i (range 10 80)] | |
(http-request | |
{:method :get | |
:url (format "http://fssnip.net/%d" i)})))) |
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 extractField = function | |
// int32 version | |
| TAtomic(t) :: TString(n) :: rest -> | |
Field(n, AtomicType(t)), rest | |
// alias version | |
| TString(alias) :: TString(n) :: rest -> | |
Field(n, AliasType(alias)), rest | |
| _ -> | |
failwith "syntax error" |
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 fib [n] | |
(loop [back1 1, back2 0, n n] | |
(cond | |
(= n 0) 0 | |
(= n 1) (+ back1 back2) | |
:else (recur back2 (+ back1 back2) (- n 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
;Scheme | |
(cond ((> 3 2) 'greater) | |
((< 3 2) 'less) | |
(else equal)) | |
;Clojure | |
(cond (> 3 2) :greater | |
(< 3 2) :less) | |
:else :equal) |
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 rec eval (env:Map<string,expression> list) expr = | |
match expr with | |
| NullExpr -> failwith "invalid interpreter state" | |
| Combination([]) -> failwith "invalid combination" | |
| Combination(h::t) -> | |
match eval env h with | |
| (nenv, Procedure(f)) -> apply f t env | |
| (nenv, Function(args, code)) -> | |
let newenv = | |
try List.fold2 bindArg (expandEnv nenv) args t |
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
IL_0000: nop | |
IL_0001: newobj instance void Program/b@12::.ctor() | |
IL_0006: ldarg.0 | |
IL_0007: ldc.i4.1 | |
IL_0008: add | |
IL_0009: tail. | |
IL_000b: call int32 Program::a(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<int32, int32="">, int32) | |
IL_0010: ret |
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
<script type="text/il-bc"> | |
public static void addInt(); | |
Code: | |
0: bipush 6 | |
2: istore_0 | |
3: bipush 17 | |
5: istore_1 | |
6: iload_0 | |
7: iload_1 | |
8: iadd |
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
int* func(int x; int y) { | |
int* p=0; | |
int s=x*y; | |
if (s!=0) | |
p=malloc(s); | |
else if(y==0) | |
p=malloc(x); | |
return p; | |
} |
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 c+ [[re1 im1] [re2 im2]] [(+ re1 re2) (+ im1 im2)]) | |
(defn c* [[re1 im1] [re2 im2]] | |
[(- (* re1 re2) (* im1 im2)) (+ (* re1 im2) (* im1 re2))]) | |
(defn c2 [c] (c* c c)) | |
(defn |c| [[re im]] (Math/sqrt (+ (* re re) (* im im)))) | |
(defn get-mandel-set [im-range re-range max-iter] | |
(for [im im-range | |
re re-range | |
:let [c [re im]]] |
OlderNewer