How to run:
$ crystal run src/bar.cr
hello from crystal
Just called a Rust function from C!
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
# All Vagrant configuration is done below. The "2" in Vagrant.configure | |
# configures the configuration version (we support older styles for | |
# backwards compatibility). Please don't change it unless you know what | |
# you're doing. | |
Vagrant.configure("2") do |config| | |
# The most common configuration options are documented and commented below. | |
# For a complete reference, please see the online documentation at |
david:~/Dropbox/projects/able/compiler $ crystal src/cli.cr -- -f ../examples/helloworld.able | |
parse tree: | |
(apply File ; id=5414918336 rule_name="File" label="" | |
(choice ; id=5414918416 label="" | |
(seq ; id=5414918496 label="" | |
(apply PackageDecl ; id=5414919936 rule_name="PackageDecl" label="" | |
(choice ; id=5414920016 label="" | |
(seq ; id=5414920096 label="" | |
"package"[id=5452605472 label=""] | |
(apply package_ident ; id=5414904128 rule_name="package_ident" label="" |
# solution to https://www.reddit.com/r/dailyprogrammer/comments/pii6j/difficult_challenge_1/ | |
def main | |
lower_bound = 1 | |
upper_bound = 100 | |
puts "Think of a number between 1 and 100, inclusive." | |
puts "At each guess, answer with 'l' to indicate your number is lower than the guess, 'h' to indicate your number is higher than the guess, or 'y' to indicate the guess is correct." | |
while true | |
guess = (lower_bound + upper_bound) / 2 | |
puts "Is #{guess} your number?" |
How to run:
$ crystal run src/bar.cr
hello from crystal
Just called a Rust function from C!
[package] | |
name = "foo" | |
version = "0.1.0" | |
authors = ["davidkellis <[email protected]>"] | |
[dependencies] | |
[lib] | |
crate-type = ["cdylib"] |
ints = File.readlines("input.txt").map(&:to_i) | |
puts ints.sum |
server: | |
address: "localhost:6667" | |
channel: "#hello" | |
greetings: | |
- passthru: true | |
filter: "boss" | |
message: "Hi, boss!" | |
- passthru: false | |
filter: ".*" |
name: "confefe" | |
version: "1.2.0" | |
tags: | |
- "foo" | |
- "bar" | |
- "baz" | |
authors: ["Bill", "Bob"] | |
dependencies: [ # dependencies captured in a nested array | |
["stdlib", "~> 1.2"], |
davidellis@davidellis:~/Dropbox/projects/benchmarks (master) $ ./run.rb | |
Running base64 benchmark suite | |
base64/crystal0.25.0 | |
base64/ruby2.5.1 | |
Running helloworld benchmark suite | |
helloworld/crystal0.25.0 | |
helloworld/ruby2.5.1 | |
Running json benchmark suite |