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
| fn selection_sort<T: PartialOrd>(v: &mut [T]) { | |
| let len = v.len(); | |
| for i in 0..len - 1 { | |
| let mut k = i; | |
| for j in i..len { | |
| if v[k] > v[j] { | |
| k = j; | |
| } | |
| } | |
| if i != k { |
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 core::ptr; | |
| fn insertion_sort<T: PartialOrd>(v: &mut [T]) { | |
| unsafe { | |
| for i in 1..v.len() { | |
| let tmp = ptr::read(v.get_unchecked(i)); | |
| let mut j = i; | |
| while j > 0 && tmp < v[j - 1] { | |
| ptr::copy_nonoverlapping(v.get_unchecked(j - 1), v.get_unchecked_mut(j), 1); | |
| j -= 1; |
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
| # EditorConfig is awesome: https://EditorConfig.org | |
| # top-most EditorConfig file | |
| root = true | |
| [*] | |
| charset = utf-8 | |
| end_of_line = lf | |
| insert_final_newline = true | |
| trim_trailing_whitespace = true |
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
| from collections import defaultdict | |
| class DFA: | |
| def __init__(self, initial_state, final_state, rules): | |
| self.initial_state = initial_state | |
| self.final_state = final_state | |
| self.rules = rules | |
| self.transitions = defaultdict(dict) |
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
| from collections import defaultdict | |
| class DFA: | |
| def __init__(self, initial_state, final_state, rules): | |
| self.initial_state = initial_state | |
| self.final_state = final_state | |
| self.rules = rules | |
| self.transitions = defaultdict(dict) |
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
| class Node<T> { | |
| public t: number; | |
| public keys: T[]; | |
| public children: Node<T>[]; | |
| public isLeaf: boolean; | |
| public constructor(t: number, isLeaf=false) { | |
| this.t = t; | |
| this.isLeaf = isLeaf; | |
| this.keys = []; |
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
| # -*- mode: ruby -*- | |
| # vi: set ft=ruby : | |
| Vagrant.configure("2") do |config| | |
| config.vm.box = "bento/ubuntu-18.04" | |
| config.vm.network :forwarded_port, guest: 22, host: 2201, id: "ssh", auto_correct: true | |
| config.vm.network "private_network", type: "dhcp" | |
| config.vm.synced_folder "./envoy", "/home/vagrant/envoy", owner: "vagrant", group: "vagrant" | |
| end |
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
| obj-m := hello.o | |
| KDIR := /lib/modules/$(shell uname -r)/build | |
| PWD := $(shell pwd) | |
| VERBOSE = 0 | |
| default: | |
| $(MAKE) -C $(KDIR) M=$(PWD) KBUILD_VERBOSE=$(VERBOSE) modules | |
| clean: |
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
| ;; 文字コードの設定 | |
| (set-language-environment 'Japanese) ; 日本語環境 | |
| (set-default-coding-systems 'utf-8-unix) | |
| (set-terminal-coding-system 'utf-8-unix) | |
| (setq default-file-name-coding-system 'utf-8) | |
| (setq default-process-coding-system '(utf-8 . utf-8)) | |
| (prefer-coding-system 'utf-8-unix) | |
| ;; C-hにバックスペースを割り当てる | |
| (define-key key-translation-map [?\C-h] [?\C-?]) |
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
| module Main where | |
| data Nat = Zero | Succ Nat deriving (Eq, Ord, Show) | |
| instance Num Nat where | |
| m + Zero = m | |
| m + Succ n = Succ (m + n) | |
| m * Zero = Zero |