This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// setting up two shaders | |
bufferPass = setupRenderPass("bufferA.frag", 1 /* toBuffer */) | |
imagePass = setupRenderPass("image.frag", 0 /* toBuffer */) | |
// inside setupRenderPass | |
renderPass setupRenderPass(shaderFile, toBuffer) { | |
// ... | |
renderPass.prog = getShader(shaderFile); | |
renderPass.iChannel0 = glGetUniformLocation(renderPass.prog, "iChannel0"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Given a string, find the length of the longest substring without (more than n) repeating characters. | |
function longestSubstringWithoutMoreThanNRepeatingCharacters(str, n) { | |
// lastSeenByCount[2]['s'] = third place we've seen 's' so far | |
let lastSeenByCount = [...Array(n).keys()].map(_ => ({})); | |
let currentLength = 0; | |
let maxLength = 0; | |
let maxLengthStart = 0; | |
let startingFrom = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn problem26-fibs [x] | |
(let [fibs | |
((fn fibs [so-far] | |
(lazy-seq | |
(fibs | |
(cons (+ (first so-far) (second so-far)) so-far) | |
))) | |
'(1 1))] | |
(take x fibs))) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.IO; | |
using System.Linq; | |
using System.Text; | |
using System.Text.RegularExpressions; | |
class Program | |
{ | |
static int Main(string[] args) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> let rec gcd = function | |
- | a 0 -> a | |
- | a b -> gcd b (a % b);; | |
| a 0 -> a | |
----^ | |
stdin(29,5): error FS0039: The pattern discriminator 'a' is not defined |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let rec loop k = | |
match () with | |
| _ when (x % k) = 0 && (x / k >= 100) && (x / k) <= 999 -> true | |
| _ when (float k) > System.Math.Sqrt (float x) -> false | |
| _ -> loop (k + 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defproject tst "0.1.0-SNAPSHOT" | |
:description "FIXME: write description" | |
:url "http://example.com/FIXME" | |
:license {:name "Eclipse Public License" | |
:url "http://www.eclipse.org/legal/epl-v10.html"} | |
:dependencies [[org.clojure/clojure "1.5.1"], | |
[prxml "1.3.1"]], | |
:main tst.core/foo) | |
(use 'clojure.contrib.prxml) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// what's printed? | |
Console.WriteLine("null is object: " + (null is object)); | |
Console.WriteLine("null is IDisposable: " + (null is IDisposable)); | |
Console.WriteLine("null is int: " + (null is int)); | |
Console.WriteLine("null is int?: " + (null is int?)); | |
Console.WriteLine("null is Func<int>: " + (null is Func<int>)); | |
Console.WriteLine("null is FileMode: " + (null is FileMode)); | |
Console.WriteLine("0 is FileMode: " + (0 is FileMode)); | |
Console.WriteLine("0 is int?: " + (0 is int?)); | |
Console.WriteLine("short over short: " + (((short)10)/((short)5)).GetType()); |