This file contains 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
require 'benchmark' | |
class Sqr | |
def initialize(xs) | |
@xs = xs | |
end | |
def run | |
puts "INLINE" | |
puts Benchmark.measure { @xs.map { |x| x * x } } |
This file contains 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
def transform(value, type = :unaltered) | |
case value | |
when Hash then value.deep_transform_keys! { |key| transform(key, type) } | |
when Symbol then transform(value.to_s, type).to_sym | |
when String | |
case type | |
when :dash then value.dasherize | |
when :camel then value.underscore.camelize | |
when :camel_lower then value.underscore.camelize(:lower) | |
when :underscore then value.underscore |
This file contains 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
def cool_method | |
found = false | |
[1,2,3,4].each (item) -> | |
if item == 2 | |
found = true | |
found | |
end |
This file contains 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 fpinscala.datastructures | |
import org.scalacheck.{Arbitrary, Gen} | |
object GenList { | |
import fpinscala.datastructures.{Cons, Nil, List} | |
def genList[A:Arbitrary]: Gen[List[A]] = for { | |
hd <- Arbitrary.arbitrary[A] | |
tl <- Gen.oneOf(nilGen, genList[A]) | |
} yield Cons(hd, tl) |
This file contains 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
--- | |
title: Home | |
published: true | |
--- | |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta http-equiv="content-type" content="text/html; charset=UTF-8"> | |
<meta charset="utf-8"> | |
<title> |