Skip to content

Instantly share code, notes, and snippets.

View jorendorff's full-sized avatar

Jason Orendorff jorendorff

View GitHub Profile
#include <stdio.h>
template <typename Head, typename... Tail>
inline void say(Head&& head, Tail&&... tail, FILE* f) {
}
int main() {
say("the magic number is ", 372, "\n", stdout);
return 0;
}
#include <utility>
#include <stdio.h>
void say(const char *s, FILE* f) {
fprintf(f, "%s", s);
}
void say(int i, FILE* f) {
fprintf(f, "%i", i);
}
static bool
StaticScopeHasLocalBinding(ExclusiveContext* cx, JSObject* scope, HandleId id)
{
for (StaticScopeIter<CanGC> scopeIter(cx, scope); !scopeIter.done(); scopeIter++) {
switch (scopeIter.type()) {
case StaticScopeIter<CanGC>::Function:
case StaticScopeIter<CanGC>::Block:
// DumpPropertyNames(cx, scopeIter.scopeShape());
if (Shape::searchNoHashify(scopeIter.scopeShape(), id))

(elevator pitch: This talk provides simple arguments in favor of functional programming. The idea is that simple arguments are more convincing and easier to remember.)

Intro

I want to talk about why you should use functional programming.

And maybe I'm preaching to the choir juuuuust a little bit, but I still think it's worth discussing this.

I added this to Cargo.toml:

[dependencies]
byteorder = "0.3.13"

At the top of my lib.rs:

extern crate byteorder;
use byteorder::{ByteOrder, LittleEndian};
#[test]
fn test_loop() {
let code = [
// Some bytecode to multiply two numbers.
OP_LOAD_U8, 6, 0, // load the number 6 into R0 (`X`, the first number to multiply)
OP_LOAD_U8, 8, 1, // load the number 8 into R1 (`Y`, the second number to multiply)
OP_LOAD_U8, 0, 2, // load the number 0 into R2 (`i`, the loop variable)
OP_LOAD_U8, 0, 3, // load the number 0 into R3 (`total`, the result variable)
OP_LOAD_U8, 1, 4, // load the number 1 into R4 - it stays there forever

October 28, 2014

  • Matt Perkins or maybe Calvin Bottoms: Word time
  • Josh Bush - show-and-tell: PewPew, a game written in Elm
  • Bryan Hunter - show-and-tell of Elixir's DocTest
  • Project Rosalind dojo

January 27, 2015

  • Dave Nolan - A first look at Nim and how to approach it functionally
// SIZE is the maximum size of List nodes.
//
// A List is made of nodes. Each node stores some slice of the List,
// a contiguous range of elements. Nodes are automatically shared
// among Lists that have a lot of elements in common. A node's data
// is stored either as a flat array of values or as a trie,
// an array of nodes.
//
// SIZE is the maximum size of all these arrays.
// So it controls the granularity of sharing between Lists.

Proof that I am not as good at computers as I think I am

Or, a conversation between a doofus and rustc.

Yehuda Katz gave a talk about Rust to Ruby people, and he had this on a slide:

fn main() {
    let v = vec![String::from("rails")]
        .tap(|v| v.extend(std::env::args()))

.tap(|v| v.push(String::from("-h")));

@jorendorff
jorendorff / random7-boring.js
Last active October 7, 2023 23:22
Make a random7 function from a random5 function.
function random7() {
while (true) {
var n = random5() + 5 * random5();
if (n < 21)
return n % 7;
}
}