Hi,
I would love to hear your opinion on the idea of “combining RDoc and RSpec to create testable documentation”. Let me explain:
Given you have several RDoc files like this one:
= Examples Some example code snippets.
| .DS_Store | |
| *.csv | |
Hi,
I would love to hear your opinion on the idea of “combining RDoc and RSpec to create testable documentation”. Let me explain:
Given you have several RDoc files like this one:
= Examples Some example code snippets.
| Loop through a given directory's subdirectories ( 1 deep) | |
| In each subdirectory check only files that are older than a day. | |
| If the file is a PDF file or zero byte move to an archive directory and log. | |
| At the end, mail the list of files, if any, to somebody. |
| import Color exposing (..) | |
| import Graphics.Collage exposing (..) | |
| import Graphics.Element exposing (..) | |
| hexagon : Color -> Form | |
| hexagon clr = outlined (solid clr) (ngon 6 150) | |
| hex_on_a_point : Float -> Color -> Form | |
| hex_on_a_point deg clr = rotate (degrees deg) (hexagon clr) |
| ;; fizzbuzz without conditionals in Clojure | |
| ; Simple patten matching using a single map lookup | |
| (defn fizzbuzz [x] | |
| (let [v [(= (mod x 3) 0) (= (mod x 5) 0)]] | |
| ({[true false] "fizz" | |
| [false true] "buzz" | |
| [true true] "fizzbuzz" | |
| [false false] x} v))) |
| #first stab | |
| h=Hash.new | |
| (File.read "grades.txt").split("\n").each do |pair| | |
| (person, grade)=pair.split ' ' | |
| if h[person] | |
| h[person] << grade.to_i | |
| else | |
| h[person]=[grade.to_i] | |
| end | |
| end |
| # stolen from rosetta code to look at later | |
| def eratosthenes(n) | |
| nums = [nil, nil, *2..n] | |
| (2..Math.sqrt(n)).each do |i| | |
| (i**2..n).step(i){|m| nums[m] = nil} if nums[i] | |
| end | |
| nums.compact | |
| end | |
| p eratosthenes(100) |
| import Color exposing (..) | |
| import Graphics.Collage exposing (..) | |
| import Graphics.Element exposing (..) | |
| hexagon : Color -> Form | |
| hexagon clr = outlined (solid clr) (ngon 6 150) | |
| hex_on_a_point : Float -> Color -> Form | |
| hex_on_a_point deg clr = rotate (degrees deg) (hexagon clr) |
| 1. | |
| function=lambda{|x| Math.sin(x)} | |
| (1..50).to_a.shuffle.take(5).map {|x| function[x]} | |
| 2. | |
| function=fn(x)-> :math.sin(x) end | |
| (1..50) |> Enum.take_random(5) |> Enum.map function | |
| 3. | |
| (def function(fn [ele] (Math/sin ele)) ) |