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 removeDupl (xs:'a list) : 'a list -> match xs with | |
| [] -> [] | |
| hd::tl -> hd :: (removeDupl (List.filter (fun x -> x <> hd ) tl));; |
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 most_frequent_elt list = | |
let rec loop maxelt maxcount elt count = function | |
| [] -> if count > maxcount then elt else maxelt | |
| x::xs -> | |
if elt = x then loop maxelt maxcount elt (count + 1) xs | |
else if count > maxcount then loop elt count x 1 xs | |
else loop maxelt maxcount x 1 xs in | |
match List.sort compare list with | |
| [] -> None | |
| x::xs -> Some (loop x 0 x 1 xs);; |
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
create table `member` ( | |
`number` int, | |
`name` varchar(256) not null, | |
`address` varchar(512) not null, | |
primary key (`number`) | |
); | |
create table `wine` ( | |
`name` varchar(256), | |
`appellation` date, |
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 count_x(char* p, char x) { | |
// count the number of occurrences of x in p[] | |
// p is assumed to point to a zero-terminated array of char (or to nothing) | |
if(p == nullptr) return 0; | |
int count = 0; | |
for(; p != nullptr; ++p) | |
if(*p == x) | |
++count; | |
return count; |
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
double sqrt(double); // the square root function takes a double | |
class Vector { | |
public: | |
Vector(int s); | |
double& operator[](int i); | |
int size(); | |
private: | |
double* elem; // elem points to an array of sz doubles |
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
#!/usr/bin/python | |
from itertools import izip | |
from datetime import datetime | |
PROFILE_PICS = [ | |
'07 September 2015', | |
'14 June 2015', | |
'09 May 2015', | |
'15 April 2015', |
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
// the class use | |
class Animal { | |
constructor(name) { | |
this.name = name; | |
} | |
walk() { | |
console.log(`${this.name} is walking`); | |
} | |
} |
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
Drop in replace functions for setTimeout() & setInterval() that | |
make use of requestAnimationFrame() for performance where available | |
http://www.joelambert.co.uk | |
Copyright 2011, Joe Lambert. | |
Free to use under the MIT license. | |
http://www.opensource.org/licenses/mit-license.php |
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
function outerFunc() { | |
// the outer scope | |
let outerVar = 'I am outside!'; | |
function innerFunc() { | |
console.log(outerVar); // -> I am outside! | |
} | |
innerFunc(); | |
} | |
outerFunc(); |
OlderNewer