Skip to content

Instantly share code, notes, and snippets.

@takscape
takscape / .xonshrc
Created January 27, 2022 14:00
.xonshrc example
# vim: ft=python
def _init():
import os.path as p
$XONSH_ENCODING = "utf-8"
$XONSH_SHOW_TRACEBACK = False
$FORCE_POSIX_PATHS = True
$XONSH_COLOR_STYLE = "monokai"
$XONSH_HISTORY_BACKEND = 'sqlite'
$PROMPT = "{env_name:{} }{BOLD_CYAN}{cwd_base}{branch_color}{curr_branch: {}}{RESET} ${RESET} "
{
"configurations": [
{
"name": "Mac",
"includePath": [
"/usr/include",
"/usr/local/include",
"${workspaceFolder}"
],
"defines": [],
#include <iostream>
#include <sstream>
#include <tuple>
using namespace std;
template <size_t Pos, typename Tpl, typename Head>
void _format_tuple(ostream& os, const Tpl& tpl) {
os << get<Pos>(tpl);
}
package ninja.util.camel.example
import org.apache.camel.CamelContext
import org.apache.camel.Exchange
import org.apache.camel.ProducerTemplate
import org.apache.camel.builder.ExchangeBuilder
import org.apache.camel.builder.RouteBuilder
import org.apache.camel.impl.DefaultCamelContext
fun CamelContext.addRoute(f : RouteBuilder.() -> Unit) {
#lang racket
(require data/heap)
(struct item
(timestamp priority id event)
#:transparent)
; x < yなら#t, x > yなら#fを返す。
; x = yなら、bodyの評価結果を返す。
fn call_f<F>(f: &F) -> i32 where F: ?Sized, F: Fn(i32) -> i32 {
f(100)
}
fn main() {
let f : Box<Fn(i32) -> i32> = Box::new(|&: x| 2 * x);
let v : i32 = call_f(&*f);
println!("{}", v);
}
fn call_f<F: ?Sized + Fn(i32) -> i32>(f: &F) -> i32 {
f(100)
}
fn main() {
let f : Box<Fn(i32) -> i32> = Box::new(|&: x| 2 * x);
let v : i32 = call_f(&*f);
println!("{}", v);
}
use std::num::Int;
use std::iter::{Iterator, iterate};
struct FibIter<'a, T:Int> {
iterator : Box<Iterator<Item=T> + 'a>
}
impl <'a, T:Int> Iterator for FibIter<'a, T> {
type Item = T;
use std::iter::{Iterator, iterate, Map, Unfold};
use std::num::Int;
type FibInternalIter<T> = Map<
(T, T), T,
Unfold<
(T, T), (fn((T, T)) -> (T, T), Option<(T, T)>, bool),
fn(&mut (fn((T, T)) -> (T, T), Option<(T, T)>, bool)) -> Option<(T, T)>>,
fn((T, T)) -> T>;
use std::iter::{Iterator, iterate};
use std::num::Int;
struct Fib<T, I> where T: Int, I: Iterator<Item=T> {
it : I
}
impl <T, I> Iterator for Fib<T, I> where
T: Int,
I: Iterator<Item=T>,