atom-fuzzy-grep
atom-jshint
color-picker
git-plus
highlight-selected
minimap
minimap-autohide
minimap-bookmarks
minimap-find-and-replace
minimap-git-diff
/* Solves one of those triangle shaped peg jumping puzzles. | |
You begin with a board composed of n rows, where the i-th | |
row contains i columns. e.g.: | |
X | |
X X | |
X X X | |
The board begins with pegs in all holes but one. A peg can | |
jump over another peg if it can land in a hole on the other | |
side. The jumped peg is removed. The goal is to finish with | |
a single peg remaining. |
#include <stdio.h> | |
#include "numbers.h" // https://gist.github.com/911872 | |
int main() | |
{ | |
struct numbers a; | |
struct numbers b; | |
/* | |
I feel like a tool, sort of. I spent more time than I should admit using | |
generateRandoms here, forgetting that mergesort can only merge two arrays |
# Greatest common divisor of more than 2 numbers. Am I terrible for doing it this way? | |
def gcd(*numbers): | |
"""Return the greatest common divisor of the given integers""" | |
from fractions import gcd | |
return reduce(gcd, numbers) | |
# Least common multiple is not in standard libraries? It's in gmpy, but this is simple enough: | |
def lcm(*numbers): |
I spent a lot of time trying to find a pretty optimal (for me) setup for Clojure… at the same time I was trying to dive in and learn it. This is never optimal; you shouldn't be fighting the environment while trying to learn something.
I feel like I went through a lot of pain searching Google, StackOverflow, blogs, and other sites for random tidbits of information and instructions.
This is a comprehensive "what I learned and what I ended up doing" that will hopefully be of use to others and act as a journal for myself if I ever have to do it again. I want to be very step-by-step and explain what's happening (and why) at each step.
I appreciate the effort you've put into documenting this, but there are a number of inaccuracies here that need to be addressed. We get
(print "Click the screen to create a new block.") | |
(def ^:const mass 10) | |
(defn get-environment | |
[] | |
(let [attr-type (attribute-type :color :ambient-light) | |
attr (attribute :color attr-type 0.3 0.3 0.3 1)] | |
(environment :set attr))) |
(def ^:const pixels-per-tile 32) | |
(defn create-ball-body! | |
[screen radius] | |
(let [body (add-body! screen (body-def :dynamic))] | |
(->> (circle-shape :set-radius radius) | |
(fixture-def :density 1 :friction 0 :restitution 1 :shape) | |
(body! body :create-fixture)) | |
body)) |
(defscreen main-screen | |
:on-show | |
(fn [screen entities] | |
(update! screen | |
:renderer (model-batch) | |
:attributes (let [attr-type (attribute-type :color :ambient-light) | |
attr (attribute :color attr-type 0.8 0.8 0.8 1)] | |
(environment :set attr)) | |
:camera (doto (perspective 75 (game :width) (game :height)) | |
(position! 0 0 3) |
(by @andrestaltz)
So you're curious in learning this new thing called (Functional) Reactive Programming (FRP).
Learning it is hard, even harder by the lack of good material. When I started, I tried looking for tutorials. I found only a handful of practical guides, but they just scratched the surface and never tackled the challenge of building the whole architecture around it. Library documentations often don't help when you're trying to understand some function. I mean, honestly, look at this:
Rx.Observable.prototype.flatMapLatest(selector, [thisArg])
Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.
- @fergbyrne
- HTM = Hierarchical Temporal Memory
- Slides
- big data is like teenage sex
- noone knows how to do it
- everyone thinks everyone else is doing it