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
| (defun mapcn (chars nums string) | |
| (loop as char across string | |
| as i = (position char chars) | |
| collect (and i (nth i nums)))) | |
| (defun parse-roman (R) | |
| (loop with nums = (mapcn "IVXLCDM" '(1 5 10 50 100 500 1000) R) | |
| as (A B) on nums if A sum (if (and B (< A B)) (- A) A))) | |
| (defun +roman (&rest rx) |
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
| (ql:quickload :cl-redis) | |
| (redis:connect :port 7777) | |
| (red:select 9) | |
| (defvar *start* 201603231200) | |
| (defvar *end* 201603231259) | |
| (defvar *bu-names* '( |
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
| (defun fetch-and-spit-player (idx) | |
| (let ((path (format nil "C:\\temp\\fpl\\~A.json" idx))) | |
| (with-open-file (fs path :direction :output | |
| :if-exists :overwrite | |
| :if-does-not-exist :create) | |
| (format t "Output: ~A~%" path) | |
| (format fs (flexi-streams:octets-to-string | |
| (drakma:http-request | |
| (format nil "http://fantasy.premierleague.com/web/api/elements/~A/" idx)) | |
| :external-format :UTF-8))))) |
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
| (dolist (x '(:hunchentoot :cl-who :parenscript :cl-fad)) | |
| (ql:quickload x)) | |
| (defpackage "EXPERIMENTS" | |
| (:use "COMMON-LISP" "HUNCHENTOOT" "CL-WHO" "PARENSCRIPT" "CL-FAD")) | |
| (in-package "EXPERIMENTS") |
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
| ⍝ This is my very first APL program, | |
| ⍝ made from scratch using an APL primer at | |
| ⍝ http://aplwiki.com/LearnApl/BuiltInFunctions | |
| ⍝ Evaluated using http://tryapl.org/ | |
| ⍝ Yields the sum of all multiples of 3 or 5 below 1000. | |
| n←⍳999⋄a←+/n×0=3|n⋄b←+/n×0=5|n⋄c←+/n×0=15|n⋄a+b-c | |
| ⍝ Second version using a function definition.. | |
| f←{+/⍺×0=⍵|⍺}⋄n←⍳999⋄a←n f 3⋄b←n f 5⋄c←n f 15⋄a+b-c |
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
| // Copyright (c) 2019 Torbjørn Marø | |
| // | |
| // This Go program is a re-implementation of the Ruby code found | |
| // in Chapter 2 of the book Mazes for Programmers by Jamis Buck. | |
| // The source contains: | |
| // - General purpose Grid implementation | |
| // - Grid to string function (ASCII maze) | |
| // - Grid to PNG function (using gg package) | |
| // - Binary Tree maze generation algorithm | |
| // - Sidewinder maze generation algorithm |
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
| using System; | |
| using System.Collections.Generic; | |
| using System.IO; | |
| using System.Linq; | |
| namespace RosettaRecursiveDirectory | |
| { | |
| class Program | |
| { | |
| static IEnumerable<FileInfo> TraverseDirectory(string rootPath, Func<FileInfo, bool> pattern) |
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 sys, os | |
| from collections import Counter | |
| def dodir(path): | |
| global h | |
| for name in os.listdir(path): | |
| p = os.path.join(path, name) | |
| if os.path.islink(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
| class Point(object): | |
| def __init__(self, x=0.0, y=0.0): | |
| self.x = x | |
| self.y = y | |
| def __repr__(self): | |
| return '<Point 0x%x x: %f y: %f>' % (id(self), self.x, self.y) | |
| class Circle(object): | |
| def __init__(self, center=None, radius=1.0): | |
| self.center = center or Point() |
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 wrap (text, limit) { | |
| if (text.length > limit) { | |
| // find the last space within limit | |
| var edge = text.slice(0, limit).lastIndexOf(' '); | |
| if (edge > 0) { | |
| var line = text.slice(0, edge); | |
| var remainder = text.slice(edge + 1); | |
| return line + '\n' + wrap(remainder, limit); | |
| } | |
| } |