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
| ;;; Mars Rover | |
| (defun move (rover cmd) | |
| (let ((compass '(NORTH EAST SOUTH WEST))) | |
| (let ((x (caar rover)) | |
| (y (cadar rover)) | |
| (h (cadr rover))) | |
| (let ((dd (case cmd ('F 1) ('B -1) (otherwise 0))) | |
| (dh (case cmd ('R 1) ('L -1) (otherwise 0))) | |
| (dx (case h ('EAST 1) ('WEST -1) (otherwise 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
| // Package main is an example of using dynamic command-line completion with | |
| // github.com/spf13/cobra. | |
| package main | |
| import ( | |
| "fmt" | |
| "os" | |
| "time" | |
| "github.com/spf13/cobra" |
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 rover::Rover; | |
| use std::{env, io}; | |
| fn main() { | |
| let mut r = match Rover::from_args(env::args()) { | |
| Ok(r) => r, | |
| Err(e) => return eprintln!("{}", e), | |
| }; | |
| println!("{}", r.report()); | |
| loop { |
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
| # Makefile | |
| lib = target/debug/foo.dylib | |
| app = bin/foo | |
| all: $(app) | |
| $(lib): src/lib.rs Cargo.toml | |
| cargo build | |
| $(app): $(lib) src/foo.cr |
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
| #!/usr/bin/env ruby | |
| # frozen_string_literal: true | |
| module ParseGitURL | |
| SSH = /^(?:[^@]+)@([^:]+):(.+)/.freeze | |
| HTTPS = %r{^https://([^/]+)/(.+)}.freeze | |
| def parse(input) | |
| case input | |
| when SSH then "#{Regexp.last_match(1)} #{Regexp.last_match(2)}" |
OlderNewer