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
(define (range start . args) | |
(let-optionals* args ((stop #f) (step 1)) | |
(define (rangei start stop ls) | |
(if (or (and (> step 0) (>= start stop)) (and (< step 0) (<= start stop))) | |
ls (rangei (+ start step) stop (cons start ls)))) | |
(cond ((= step 0) (error "Step cannot take 0")) | |
((not (integer? start)) (error "Integer required for 1st argument, but got:" start)) | |
((and stop (not (integer? stop))) (error "Integer required for 2nd argument, but got:" stop)) | |
((not (integer? step)) (error "Integer required for 3rd argument, but got:" step)) | |
((not stop) (reverse (rangei 0 start '()))) |
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
class MyMeta(type): | |
def __new__(meta_cls, name, bases, dic): | |
print '__new__(meta_cls=%s, name=%s, bases=%s, dic=%s)' % (meta_cls, name, bases, dic) | |
return type.__new__(meta_cls, name, bases, dic) | |
def __init__(cls, name, bases, dic): | |
from inspect import isfunction | |
print '__init__(cls=%s, name=%s, bases=%s, dic=%s)' % (cls, name, bases, dic) | |
type.__init__(cls, name, bases, dic) | |
for k, v in cls.__dict__.iteritems(): |
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
import java.util.concurrent.*; | |
import java.util.Arrays; | |
import java.util.stream.Collectors; | |
public class StreamEtude{ | |
public static void main (String[] args) { | |
ExecutorService exe = Executors.newFixedThreadPool(4); | |
Arrays.stream(args) | |
.map(Integer::parseInt) | |
.map( arg -> exe.submit(() -> fib(arg)) ).collect(Collectors.toList()).stream() |
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
import java.util.function.*; | |
import java.util.Arrays; | |
import java.util.stream.Collectors; | |
public class WrapFunc{ | |
public static void main (String[] args) { | |
Arrays.stream(args).map(Integer::parseInt).map(Throwables.ignore(WrapFunc::fib)) | |
.forEach(Throwables.ignore(WrapFunc::myPrint)); | |
} | |
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
import java.util.Optional; | |
import java.util.function.Consumer; | |
public class Application1 { | |
public static void main (String[] args) { | |
let(new ArrayWrapper<String>(args), a ->{ | |
System.out.println(fullName(a.get(0), a.get(1)).orElse("Failure")); | |
}); | |
} |
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
#include <iostream> | |
#include <regex> | |
#include <string> | |
int main(int argc, char const* argv[]) | |
{ | |
using namespace std; | |
regex r("hoge:(abc)"); | |
smatch res; | |
string input = "hoge:abc"; |
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
csize = `stty size`.scan(/\d+/).map(&:to_i) | |
puts "\033[2J" | |
x = 0 | |
Train = "\xf0\x9f\x9a\x83 " | |
TLength = 10 | |
speed = 1 | |
loop{ | |
print "\033[2J" | |
print "\033[#{csize[0]};#{x}H#{Train*TLength}\033[0;0H" | |
x += speed |
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
WITH RECURSIVE _fib(a, b) AS ( | |
SELECT 1,0 | |
UNION ALL | |
SELECT b, a+b FROM _fib | |
), fib AS ( | |
SELECT b FROM _fib | |
) | |
SELECT * FROM fib LIMIT 100; |
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
#include <iostream> | |
#include <iomanip> | |
#include <type_traits> | |
constexpr int N = 10; | |
constexpr int max_k = 100; | |
double dp[N][max_k+1]; | |
#ifdef DEBUG | |
template<class 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
#include <stdio.h> | |
i = 1; | |
main() | |
{ | |
(i % 3 || printf("fizz")) && | |
(i % 5 || printf("buzz")) && | |
(!(i % 3 && i % 5) || printf("%d", i)) && | |
printf("\n") && | |
(++i > 100 || main()); | |
} |
OlderNewer