(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
| import bisect | |
| class NFA(object): | |
| EPSILON = object() | |
| ANY = object() | |
| def __init__(self, start_state): | |
| self.transitions = {} | |
| self.final_states = set() | |
| self._start_state = start_state |
| """ | |
| (C) Mathieu Blondel - 2010 | |
| License: BSD 3 clause | |
| Implementation of the collapsed Gibbs sampler for | |
| Latent Dirichlet Allocation, as described in | |
| Finding scientifc topics (Griffiths and Steyvers) | |
| """ |
| def deBruijn(n, k): | |
| ''' | |
| An implementation of the FKM algorithm for generating the de Bruijn | |
| sequence containing all k-ary strings of length n, as described in | |
| "Combinatorial Generation" by Frank Ruskey. | |
| ''' | |
| a = [ 0 ] * (n + 1) | |
| def gen(t, p): |
| -- This is going to be on Hackage soon! https://github.com/gatlin/surely | |
| {-# LANGUAGE BangPatterns #-} | |
| -- | | |
| -- Module : AI.Surely | |
| -- Copyright : 2012 Gatlin Johnson | |
| -- License : LGPL 3.0 | |
| -- Maintainer : [email protected] | |
| -- Stability : experimental |
| public final class IntrusiveList<T> { | |
| /** private constructor used by makeList() */ | |
| private IntrusiveList() { | |
| t = null; // is null so we know this must be the head/tail | |
| prev = next = this; // cyclic | |
| } | |
| /** returns a new head/tail pointer */ | |
| public static <T> IntrusiveList<T> makeList() { |
| % Introduce reflexive equality | |
| refl(X, X). | |
| % Introduce symmetrical equality | |
| sym(X, Y) :- | |
| refl(X, Y), | |
| refl(Y, X). | |
| % Identity of addition by zero | |
| add_zero(N) :- |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
| // Let's say we have a gradle plugin. Now we want that gradle plugin project to actually use the exact plugin. | |
| // There are probably multiple ways we can bootstrap this. One way is to build the jar, and use that, but that's boring. | |
| // Here we show how we can have the plugin-project use the actual plugin we are building. | |
| // :: We load the groovy script on runtime, only then are we able to apply the plugin | |
| // Setup the groovy classpath. Start with our own files | |
| def classpaths = [file('src/main/groovy').absolutePath, file('src/main/resources').absolutePath] | |
| // The groovy script engine wants a string array | |
| String[] classpathArray = classpaths.toArray(new String[classpaths.size()]); | |
| // Start a groovy script engine with our classpaths |
| import static java.lang.System.*; | |
| import java.util.function.BiFunction; | |
| import java.util.function.Function; | |
| // Implementation of a pseudo-GADT in Java, translating the examples from | |
| // http://www.cs.ox.ac.uk/ralf.hinze/publications/With.pdf | |
| // The technique presented below is, in fact, just an encoding of a normal Algebraic Data Type | |
| // using a variation of the visitor pattern + the application of the Yoneda lemma to make it | |
| // isomorphic to the targeted 'GADT'. |
| <templateSet group="android"> | |
| <template name="focvb" value="@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_$END$, container, false); ButterKnife.inject(this, view); return view; } " description="Fragment onCreateView with ButterKnife" toReformat="true" toShortenFQNames="true"> | |
| <context> | |
| <option name="JAVA_CODE" value="false" /> | |
| <option name="JAVA_STATEMENT" value="false" /> | |
| <option name="JAVA_EXPRESSION" value="true" /> | |
| <option name="JAVA_DECLARATION" value="true" /> | |
| <option name="JAVA_COMMENT" value="false" /> | |
| <option name="JAVA_STRING" value="false" /> | |
| <option name="COMPLETION" value="false" /> |