This file contains hidden or 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 fizzbuzz [n] | |
| (let [all-nums (range 0 n) | |
| folder (fn [fb-str p-num fb-coll] | |
| (mapcat (fn [x] (cons fb-str (rest x))) | |
| (partition-all p-num fb-coll))) | |
| fizz (folder "fizz" 3 all-nums) | |
| buzz (folder "buzz" 5 fizz) | |
| fizzbuzz (folder "fizzbuzz" 15 buzz)] | |
| fizzbuzz)) |
This file contains hidden or 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
| ;; Get a 1Mn random numbers to calculate entropy over | |
| (def ps (vec (repeatedly 1e6 rand))) | |
| ;; entropy function | |
| (defn entropy [p] | |
| (* p (Math/log p))) |
This file contains hidden or 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
| (def vowel? (set "aeiou")) ; sets are functions of their items (to test contains) | |
| (defn pig-latin [word] | |
| ; word is expected to be a string | |
| ; which can be treated like a sequence of characters. | |
| (let [first-letter (first word)] ; assigns a local variable | |
| (if (vowel? first-letter) | |
| (str word "ay") ; then part of if | |
| (str (subs word 1) first-letter "ay")))) ; else part of if |
This file contains hidden or 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 chr->int [c] | |
| (-> (char c) | |
| (str) | |
| (Integer.))) |
This file contains hidden or 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
| <script id="echochamber"> | |
| var EchoChamber = window.EchoChamber || {}; | |
| (function() { | |
| EchoChamber.discussionURL = window.location; | |
| var script = document.createElement('script'); | |
| script.src = 'https://s3.amazonaws.com/echochamberjs/dist/main.js'; | |
| script.async = true; | |
| var entry = document.getElementById('echochamber'); | |
| entry.parentNode.insertBefore(script, entry); | |
| })(); |
This file contains hidden or 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
| from pyspark import SparkContext | |
| from pyspark.sql import SQLContext | |
| from pyspark.sql.types import * | |
| from IPython.display import display | |
| sc = SparkContext(appName="CarCSV") | |
| sqlContext = SQLContext(sc) | |
| schema = StructType([StructField("year", IntegerType(), False), | |
| StructField("make", StringType(), False), |
This file contains hidden or 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
| div, span { | |
| box-sizing: border-box; | |
| position: relative; | |
| display: flex; | |
| flex-direction: column; | |
| align-items: stretch; | |
| flex-shrink: 0; | |
| border: 0 solid black; |
This file contains hidden or 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
| (ns ruby-to-clojure.seq-utils) | |
| (defn map-with-index | |
| "Like clojure/map, but f should accept 2 arguments: the element and its index | |
| in the collection." | |
| [f coll] | |
| (map f coll (iterate inc 0))) | |
| (defn some-index | |
| "Returns the index of the first element of coll for which (f elem) returns |
This file contains hidden or 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
| pyg = 'ay' | |
| original = raw_input('Enter a word:') | |
| word=original.lower() | |
| first = word[0] | |
| new_word=word+first+pyg | |
| new_word=new_word[1:len(new_word)] | |
| if len(original) > 0 and original.isalpha(): | |
| print new_word |
This file contains hidden or 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
| #include <iostream> | |
| #include <vector> | |
| #include <algorithm> | |
| /** | |
| Example showing the function programming ideas in | |
| C++ 11. Features used here are part of standard language. | |
| **/ | |
| template <typename Collection,typename unop> |