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
| import math | |
| def multtab(n): | |
| width = 1 + int(math.ceil(math.log(n)/math.log(10))) | |
| format_str = '%' + str(width) + "d" | |
| for row in range(1,n+1): | |
| for col in range(1,n+1): | |
| print format_str % (row * col), | |
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 lower_text(text): | |
| return " ".join(map(lambda w: str.lower(w), text.split())) | |
| if __name__ == "__main__": | |
| print "Enter some text in mixed-case" | |
| input = raw_input() | |
| print lower_text(input) |
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 thanks [name reason] | |
| (println (format "Hey %s, thanks for %s!" name reason))) | |
| (thanks "Posterous" "github gist auto-expands") |
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
| import java.io.*; | |
| import java.util.*; | |
| public class LineBreaker | |
| { | |
| public static void main(String[] args) | |
| { | |
| if (args.length < 1) { | |
| System.err.println("Give the name of the file as an argument."); | |
| System.exit(1); |
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 <cmath> | |
| using namespace std; | |
| int main() { | |
| double CostOfItem; | |
| double NumberYears; | |
| double Inflation; | |
| double Result; |
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
| import Data.List (delete, permutations, intercalate) | |
| import System.Random | |
| type Person = String | |
| type SantaSuggestion = [(Person, Person)] | |
| people :: [Person] | |
| people = ["Chris", "Sarah", "Matt", "Jimmy", "Colin", "Kelsey", "Peter"] | |
| -- main function chooses from the lowest-scoring (least bad) |
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
| class Hash | |
| def true_of?(subject_key, &block) | |
| TrueOf.new(self).instance_eval(&block) | |
| end | |
| end | |
| class TrueOf | |
| attr_reader :value, :key | |
| def initialize(hash, key, &block) |
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
| function login_page() { | |
| login = CLogin.make("", CLogin.default_config("test", function(_, _){some(true)})); | |
| xml = CLogin.html(login); | |
| Resource.page("Login page", page_template(xml)) | |
| } |
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
| .TL | |
| Request for Funds In Support of An Expedition to the Antarctic | |
| Continent | |
| .AU | |
| William Dyer Ph.D. | |
| .AI | |
| Professor of Geology, Miskatonic University | |
| .AB | |
| Being a request for funds necessary to support a lively expedition | |
| to the southernmost continent of the world. Reasons for the outlays |
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
| import Control.Monad.Reader | |
| import Prelude hiding (last) | |
| import Text.Printf | |
| import qualified Data.Map as M | |
| type PersonInfo = Reader (M.Map String String) String | |
| gimmie :: String -> PersonInfo | |
| gimmie key = asks (M.findWithDefault "" key) |