Skip to content

Instantly share code, notes, and snippets.

// g++ -std=c++0x random.cpp -o random
#include <iostream>
#include <random>
#include <functional>
class RandomGenerator {
private:
std::mt19937 e_;
std::uniform_real_distribution<long double> dist_;
// g++ -std=c++11 `pkg-config gtkmm-2.4 --cflags --libs` -o gtkmm gtkmm.cpp
#include <gtkmm/drawingarea.h>
#include <gtkmm/main.h>
#include <gtkmm/window.h>
#include <cairomm/context.h>
class IchimatsuArea : public Gtk::DrawingArea
{
public:
// g++ -std=c++11 `pkg-config gtkmm-2.4 --cflags --libs` -o menu menu.cpp
#include <iostream>
#include <gtkmm.h>
#include <gtkmm/stock.h>
class MenuWindow: public Gtk::Window {
public:
MenuWindow() {
add(m_Box);
@mkamotsu
mkamotsu / min.cpp
Created June 3, 2013 17:02
std::min_elementで0でない最小値を探すための比較関数 ref: http://qiita.com/items/e7918d3416c5ae6a1102
#include <iostream>
#include <vector>
#include <algorithm>
using std::vector;
using std::cout;
using std::endl;
int main() {
vector<int> a = {5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5};
auto min = min_element(a.begin(), a.end(), [](int a, int b) {
return ((a != 0) && (b == 0)) || a < b;
@mkamotsu
mkamotsu / min.cpp
Created June 3, 2013 17:15
std::min_elementで0でない最小値を見つけるための比較関数 ref: http://qiita.com/items/bd65c5473f5ef238d9cd
#include <iostream>
#include <vector>
#include <algorithm>
using std::vector;
using std::cout;
using std::endl;
int main() {
vector<int> a = {0, 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5, 0};
auto min = min_element(a.begin(), a.end(), [](int a, int b) {
return (a == 0) ? false : (b == 0) || a < b;
(reduce #'+ (mapcar #'rest
'((LAND-OF-LISP . 3990)
(PAIP . 9660)
(ANSI-COMMON-LISP . 3570)
(ON-LISP . 3800)
(LET-OVER-LAMBDA . 3200))))
@mkamotsu
mkamotsu / expand.lisp
Created June 7, 2013 07:12
(expand t "${FOO} ${BAR}")を (format t "~A ~A" FOO BAR)に変換するマクロ
(ql:quickload :cl-ppcre)
(defpackage :expand
(:use :cl :ppcre))
(in-package :expand)
(defconstant +regex+ "\\$\\{(.*?)\\}")
(defun expand-string (string)
(defun nn (n)
(let ((*print-base* n))
(loop for i from 1 below n
do (loop for j from 1 below n
do (format t "~2A " (* i j)))
do (terpri))))
@mkamotsu
mkamotsu / which.c
Created July 17, 2013 07:14
満場一致でBのほうが書きやすい/読みやすいと言われたけどマジなの……
#include <stdio.h>
void A(void) {
int i;
for (i=0; i<100; ++i) {
printf("%d %g %g\n", i, (i / 10 + 1) * 0.1, (i % 10 + 1) * 0.1);
}
}
void B(void) {
(setq initial-frame-alist
'((width . 100)
(height . 39)
(top . 0)
(left . 0)
(font . "VL Gothic-10")))
(setq default-frame-alist initial-frame-alist)
(show-paren-mode 1)