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
| // CPU EMULATOR | |
| // CPUの作り方10講3章 | |
| #![allow(unused)] | |
| use std::num::Wrapping; | |
| // 命令コードのインデックス | |
| const MOV: u16 = 0; | |
| const ADD: u16 = 1; | |
| const SUB: u16 = 2; |
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 bubble_sort(values: &Vec<i32>) -> Vec<i32> { | |
| let mut result = values.clone(); | |
| for i in 0..(values.len() - 2) { | |
| for base in 0..(values.len() - i) { | |
| let target_index = base + 1; | |
| if target_index >= values.len() { | |
| break; | |
| } |
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
| // lifegame | |
| // 生→1 | |
| // 死→0 | |
| fn is_birth(target_row: i32, target_col: i32, field: &Field) -> bool { | |
| if field[target_row as usize][target_col as usize] == 1 { | |
| return false; | |
| } | |
| let mut count = 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
| // $ cargo +nightly --version # you need to use rustc nightly version | |
| // cargo 1.39.0-nightly (3596cb86b 2019-09-19) | |
| // $ cargo +nightly bench --features unstable | |
| // Compiling ackermann-calc v0.1.0 (/home/mizukmb/src/ackermann-calc) | |
| // Finished release [optimized] target(s) in 1.12s | |
| // Running target/release/deps/ackermann_calc-83e1a1843dd244b1 | |
| // | |
| // running 9 tests | |
| // test tests::a0 ... ignored | |
| // test tests::a1 ... ignored |
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
| #!/bin/sh | |
| word='' | |
| if [ -p /dev/stdin ]; then | |
| word=$(cat -) | |
| else | |
| word=$1 | |
| fi | |
| echo :ejoneco: \< $word |
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
| format: | |
| subject: '### %{subject}' | |
| line: '- [%{title}](%{url}) by [:@%{user}: @%{user}](https://github.com/%{user}) %{status}' | |
| dictionary: | |
| status: | |
| merged: '**merged!**' | |
| closed: '**closed!**' |
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
| import Control.Exception | |
| import Data.List | |
| import System.Directory | |
| import System.Environment | |
| import System.IO | |
| dispatch :: String -> [String] -> IO () | |
| dispatch "add" = add | |
| dispatch "view" = view | |
| dispatch "remove" = remove |
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
| import System.IO | |
| import System.Directory | |
| import Data.List | |
| import Control.Exception | |
| main = do | |
| contents <- readFile "todo.txt" | |
| let todoTasks = lines contents | |
| numberedTasks = zipWith (\n line -> show n ++ " - " ++ line) [0..] todoTasks |
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
| import System.IO | |
| main = do | |
| todoItem <- getLine | |
| appendFile "todo.txt" (todoItem ++ "\n") |
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
| import Data.Char | |
| -- main = putStrLn "Hello, World" | |
| -- main = do | |
| -- putStrLn "Hello, what's your name?" | |
| -- name <- getLine | |
| -- putStrLn ("Hey " ++ name ++ ", you rock!") | |
| main = do | |
| putStrLn "What's your first name?" |
NewerOlder