How to run:
$ crystal run src/bar.cr
hello from crystal
Just called a Rust function from C!
ints = File.readlines("input.txt").map(&:to_i) | |
puts ints.sum |
[package] | |
name = "foo" | |
version = "0.1.0" | |
authors = ["davidkellis <[email protected]>"] | |
[dependencies] | |
[lib] | |
crate-type = ["cdylib"] |
How to run:
$ crystal run src/bar.cr
hello from crystal
Just called a Rust function from C!
# 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?" |
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="" |
# -*- 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 |