This file contains hidden or 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
| 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)) |
This file contains hidden or 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
| open Core.Std;; | |
| exception Cannot_read_from_stdin;; | |
| type guess_result = { | |
| right_position: int; | |
| wrong_position: int | |
| };; | |
| let judge_guess guessed answer = |
This file contains hidden or 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 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 |
This file contains hidden or 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> | |
| class Aab { | |
| public: | |
| int b_ = 0; | |
| float c_ = 0; | |
| Aab(int b) { | |
| this->b_ = b; | |
| } |
This file contains hidden or 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> | |
| template<int n> | |
| struct fibonacci | |
| { | |
| static constexpr int value = fibonacci<n-1>::value + fibonacci<n-2>::value; | |
| }; | |
| template<> | |
| struct fibonacci<0> | |
| { |
This file contains hidden or 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 <fstream> | |
| auto try1(void) { | |
| std::ofstream outfile("/tmp/k.txt"); | |
| return outfile; | |
| } | |
| int main(void) { | |
| auto outfile = try1(); |
This file contains hidden or 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> | |
| int main(void) { | |
| for (int i = 0; i < 100; i += 1) { | |
| puts("n"); | |
| } | |
| puts("y"); | |
| } |
This file contains hidden or 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
| 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 { |
This file contains hidden or 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
| 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 { |
This file contains hidden or 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
| (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)) |