This file contains hidden or 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
| // g++ -o gauss gauss.cpp -DTYPE=Number | |
| #include <cstdio> | |
| #include <cstdlib> | |
| // some helper functions and classes | |
| static int gcd (int a, int b) { | |
| if (b == 0) return a; | |
| else return gcd (b, a%b); | |
| } |
This file contains hidden or 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
| function curve(x) { | |
| return Math.sqrt(1 - x * x); | |
| } | |
| function curveInt(x) { | |
| return 0.5*(Math.sqrt(1-x*x)*x+Math.asin(x)); | |
| } | |
| function corner(x, y, w, h) { | |
| if ((x+w)*(x+w)+(y+h)*(y+h) <= 1) return 1; | |
| if (x*x+y*y >= 1) return 0; | |
| //if (x > 1 || y > 1) return 0; |
This file contains hidden or 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
| protocol Creatable { | |
| init() | |
| } | |
| func create<T: Creatable>(f: (T) -> Void) -> T { | |
| let t = T() | |
| f(t) | |
| return t | |
| } |
This file contains hidden or 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
| function fish_prompt | |
| set prompt (prompt_pwd) | |
| if set branch (git rev-parse --abbrev-ref HEAD ^/dev/null) | |
| set prompt $prompt (set_color $fish_color_autosuggestion) ' | ' (set_color normal) $branch (set_color normal) | |
| end | |
| set prompt $prompt (set_color $fish_color_autosuggestion) ' > ' (set_color normal) | |
| echo -n -s $prompt | |
| end |
This file contains hidden or 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
| #include <cstdio> | |
| class Printer; | |
| class Printable { | |
| public: | |
| virtual void print (Printer& printer) const = 0; | |
| }; | |
| class Printer { |
This file contains hidden or 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
| #include <cstdlib> | |
| template <class T> class Array2D { | |
| int size, stride; | |
| T* data; | |
| public: | |
| Array2D (int m, int n): size(m*n), stride(n) { | |
| data = (T*) malloc (size*sizeof(T)); | |
| for (int i=0; i<size; i++) | |
| new (data + i) T (); |
NewerOlder