Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View roberthoenig's full-sized avatar

Robert Hönig roberthoenig

  • ETH Zurich
  • Zurich, Switzerland
View GitHub Profile
@roberthoenig
roberthoenig / fibonacciIterable.jl
Created July 26, 2018 19:14
Defining an iterator over the fibonacci sequence in Julia.
struct Fibonacci{I}
first::I
second::I
end
function Base.iterate(iter::Fibonacci, state=nothing)
if state == nothing
iter.first, (iter.first, nothing)
elseif state[2] == nothing
iter.second, (iter.first, iter.second)
@roberthoenig
roberthoenig / ycombinator.jl
Created March 19, 2018 20:52
Julia implementation of a Y combinator, together with an exmplae implementation of factorials.
# Define a strict Y combinator function.
Y = (f) -> ((x)->(f((y)->((x(x))(y)))))(
(x)->(f((y)->((x(x))(y))))
)
# Use the Y combinator the implement a factorial function.
factorialbasefunc = (f) -> ((n)->(n==0 ? 1 : n*f(n-1)))
factorial = Y(factorialbasefunc)
println(factorial(5)) # 120
@roberthoenig
roberthoenig / zulip_gci_bots.md
Created November 16, 2017 12:16
Ideas for interactive bot tasks for Zulip GCI
  • Google hangouts bot (e.g. "@hangouts call" would post a link for others to join)

  • lunch bot (similar to https://lunchtrain.builtbyslack.com/): user creates lunch event; others subscribe with PMs to the bot; lunch bot updates the original lunch event

  • game bots! chess, merels, four in a row, hangman (hangman was actually a proposal during last GCI)

  • RSS feed bot

  • GMail bot

@roberthoenig
roberthoenig / zulip_git_flows.md
Last active November 14, 2017 12:15
Some copy-paste git commands for the Zulip git workflow.

These are messages you can directly use for responding to many common git questions.

Updating master

Enter the following commands one by one into your command line:
```.sh
git checkout master
git fetch upstream
git rebase upstream/master
```
@roberthoenig
roberthoenig / lisparser.py
Created August 26, 2017 19:48
Simple Lisp parser for Python 3.
import sys
from typing import Any, List
# Parse input string into a list of all parentheses and atoms (int or str),
# exclude whitespaces.
def normalize_str(string: str) -> List[str]:
str_norm = []
last_c = None
for c in string:
@roberthoenig
roberthoenig / FourInARow.cpp
Last active August 13, 2017 17:32
This is a text-based implementation of the game "Four in a row".
#include <iostream>
#include <stdexcept>
#include <vector>
enum State {
RUNNING,
DRAW,
VICTORY_P1,
VICTORY_P2
};
@roberthoenig
roberthoenig / contrib_bots_next_phase.md
Last active January 14, 2017 15:45
Discuss the next phase and development goals for Zulip bots

Note

The ideas mentioned here mostly originated from discussions on the Zulip chat Feel free to discuss their implementation there, or add improvements of these ideas, or new ideas in the comments.

Structuring proposals

Rename contrib_bots