I can only rebind a variable that is explicitly declared as mutable; cool.
fn main() {
let mut x: int = 5;
x = 10i;
println!("value of x: {}", x); // -> 10
}
### Keybase proof | |
I hereby claim: | |
* I am jbowles on github. | |
* I am jbowles (https://keybase.io/jbowles) on keybase. | |
* I have a public key whose fingerprint is 18A2 A842 FEB6 3E60 3CB3 AC80 3A7B 98D5 D2AA FE72 | |
To claim this, I am signing this object: |
defmodule WordCounter do | |
def count(sent) do | |
sent |> normalize |> find_words |> count_unique |> Enum.sort() | |
end | |
def find_words(sent) do | |
Regex.scan(~r/\w+/, sent) | |
end |
I can only rebind a variable that is explicitly declared as mutable; cool.
fn main() {
let mut x: int = 5;
x = 10i;
println!("value of x: {}", x); // -> 10
}
// Using the Unicode Names package: http://www.rust-ci.org/huonw/unicode_names/doc/unicode_names/#cargo-enabled | |
//require macros... | |
// in Cargo.toml looks like this: | |
// [dependencies.unicode_names_macros] | |
// git = "https://github.com/huonw/unicode_names" | |
#![feature(phase)] | |
#[phase(plugin)] extern crate unicode_names_macros; |
# mongo_template.rb | |
# remove unneeded defaults | |
run "rm public/index.html" | |
run "rm public/images/rails.png" | |
run "rm public/javascripts/controls.js" | |
run "rm public/javascripts/dragdrop.js" | |
run "rm public/javascripts/effects.js" | |
run "rm public/javascripts/prototype.js" |
MONKEY_PATCHES = {} | |
module MonkeyPatcher | |
begin | |
errors = [] | |
port = Mongo::Connection::DEFAULT_PORT | |
begin | |
db_conn = Mongo::Connection.new('host', port).db('db') | |
db_error = Mongo::Connection.new('host', port).db('db') |
#!/usr/bin/env python | |
def builder(string1,string2): | |
return string1 + ' ' + string2 | |
def insert(string_list): | |
return [char +'-' for char in string_list] | |
def joiner(string_list): | |
return ''.join(x for x in string_list) |
var first = function(){return 'first';}, | |
second = function(){return 'second';}, | |
func_one = function(someFunction, someValue){someFunction(someValue);}, | |
func_two = function(anotherFunction, anotherValue){anotherFunction(anotherValue);}; | |
function say(word) {console.log(word);} | |
function speak(anotherWord) {console.log(anotherWord);} | |
/* | |
* run the two functions above |
def func_one | |
func_one = lambda do | |
puts "lambda_one" | |
end | |
#func_one.call | |
end | |
def func_two | |
func_two = lambda do | |
puts "lambda_two" | |
end |
# Use case for goldmine: | |
# the pivoting functionality of Goldmine#dig allows you to easily mine data | |
# from Mongo collections | |
require 'goldmine' | |
require 'mongo' | |
require 'yajl' | |
class Digger | |
# Convenience for connecting to MongoDB database instance on localhost |