Skip to content

Instantly share code, notes, and snippets.

open Core.Std;;
let perm ~f l =
let rec perm2 f2 l2 cl =
if l2 = []
then f2 (List.rev cl)
else List.iteri
l2 ~f:(fun i x ->
let (a, b) = List.split_n l2 i in
perm2 f2 (List.append a (List.tl_exn b)) (List.hd_exn b :: cl))
open Core.Std;;
exception Cannot_read_from_stdin;;
type guess_result = {
right_position: int;
wrong_position: int
};;
let judge_guess guessed answer =
/* Define this type if we are doing the whole job,
or if we want this type in particular. */
#if defined (_STDDEF_H) || defined (__need_size_t)
#ifndef __size_t__ /* BeOS */
#ifndef __SIZE_T__ /* Cray Unicos/Mk */
#ifndef _SIZE_T /* in case <sys/types.h> has defined it. */
#ifndef _SYS_SIZE_T_H
#ifndef _T_SIZE_
#ifndef _T_SIZE
#ifndef __SIZE_T
#include <iostream>
class Aab {
public:
int b_ = 0;
float c_ = 0;
Aab(int b) {
this->b_ = b;
}
#include <iostream>
template<int n>
struct fibonacci
{
static constexpr int value = fibonacci<n-1>::value + fibonacci<n-2>::value;
};
template<>
struct fibonacci<0>
{
#include <fstream>
auto try1(void) {
std::ofstream outfile("/tmp/k.txt");
return outfile;
}
int main(void) {
auto outfile = try1();
#include <stdio.h>
int main(void) {
for (int i = 0; i < 100; i += 1) {
puts("n");
}
puts("y");
}
use std::{env, fs, io};
use std::io::Read;
fn format_02x_8u8(data: &[u8], missing_value: String) -> String {
if data.len() >= 8 {
return format!("{:02x} {:02x} {:02x} {:02x} {:02x} {:02x} {:02x} {:02x}",
data[0], data[1], data[2], data[3],
data[4], data[5], data[6], data[7]);
} else {
use std::{env, fs, io};
use std::io::Read;
fn format_02x_8u8(data: &[u8], missing_value: String) -> String {
if data.len() >= 8 {
return format!("{:02x} {:02x} {:02x} {:02x} {:02x} {:02x} {:02x} {:02x}",
data[0], data[1], data[2], data[3],
data[4], data[5], data[6], data[7]);
} else {
(use-modules (srfi srfi-1)
(ice-9 pretty-print))
(define (sum ls)
(if (null? ls)
0
(+ (car ls) (sum (cdr ls)))))
(define (sum2 ls)
(apply + ls))