This shows how different approaches to memoization work (or don't) in different Ruby engines.
If you're using the idiomatic Ruby approach to memoization, like this:
def data
@memo ||= expensive_action
end
class NoiseCensor | |
def initialize(chars = "&^%@*#") | |
@noise = chars.split(//).shuffle.cycle | |
end | |
def censor(text) | |
@noise.take(text.length).join | |
end | |
end |
# https://en.wikipedia.org/wiki/Damm_algorithm | |
module Damm | |
extend self | |
OP_TABLE = [ | |
[0, 3, 1, 7, 5, 9, 8, 6, 4, 2], | |
[7, 0, 9, 2, 1, 5, 4, 8, 6, 3], | |
[4, 2, 0, 6, 8, 7, 1, 3, 5, 9], | |
[1, 7, 5, 0, 9, 8, 3, 4, 2, 6], |
use std::io; | |
use std::io::BufRead; | |
mod luhn { | |
pub fn luhn(cardn: &str) -> bool { | |
let chars : Vec<char> = cardn.chars().collect(); | |
let mut sum = 0; | |
let len = chars.len(); | |
for ridx in 1..=len { |
class Circuit | |
class OKResult | |
def initialize(value) | |
@value = value | |
end | |
def if_break(&blk) | |
self |
require 'benchmark' | |
require "benchmark/memory" | |
N = 10_000_000 | |
nonlazy = ->{ (1..N) .select(&:even?).map{|i| i*2 }.map{|i| i + 1 }.map(&:to_s).map(&:reverse).to_a.join(",").length } | |
lazy = ->{ (1..N).lazy.select(&:even?).map{|i| i*2 }.map{|i| i + 1 }.map(&:to_s).map(&:reverse).to_a.join(",").length } | |
one = ->{ | |
(1..N).each_with_object([]) do |i,a| | |
if i.even? |
"the government borrows from it... the government could borrow more money to pay it back" | |
No it doesn't. No it couldn't. Please please PLEASE read up on the structure of the Social Security system before parroting the right-wing line on this. (Did you notice your link here was to an advocate of privatization?) | |
Social Security payments are made from the current year's Social Security tax. Any surplus collected is, by law, used to purchase (essentially) Treasury securities. This is intragovernmental debt -- it's money the government owes itself. It's actually a huge part of our current federal debt. | |
The federal government then goes on to spend that money on services like any other revenue. It could potentially sequester that revenue in a fund, but what would it invest it in? What form of savings is more reliable than Treasury securities? You can't just pile up money in a vault somewhere. So the government doesn't "borrow" from the Social Security Trust Fund -- the government's debt IS the Social Security T |
Troi's mom nails a cuddly science bear from the Kevorkian sector.
http://tng.trekcore.com/hd/albums/season-4/4x22/half-a-life-hd-239.jpg
#include <czmq.h> | |
#include <bstrlib.h> | |
const char* shouter_addr = "inproc://shouter"; | |
const char* listener_addr = "inproc://listener"; | |
const char* ui_addr = "inproc://ui"; | |
// Simulation Thread | |
typedef struct simulation_arg_t |
require 'ffi-rzmq' | |
inport, outport, label = ARGV[0], ARGV[1], ARGV[2] | |
context = ZMQ::Context.new(1) | |
simulation = Thread.new do | |
shoutsock = context.socket(ZMQ::PAIR) | |
shoutsock.bind("inproc://shouter") |