Elixir's pipeline operator |>
apparently passes the result of each step as the first parameter to the next, so
iex> [1, [2], 3] |> List.flatten |> Enum.map(fn x -> x * 2 end)
[2, 4, 6]
is equivalent to
commit d37cb54df270fd6bd1b7464af2bc3e285079cdc5 | |
Author: bodhi | |
Date: Sat Dec 19 21:53:27 2009 +1100 | |
Create event when drag-n-dropping non-file URLs on Nextstep | |
diff --git a/lisp/term/ns-win.el b/lisp/term/ns-win.el | |
index 157b2dd..13bd0ac 100644 | |
--- a/lisp/term/ns-win.el | |
+++ b/lisp/term/ns-win.el |
pasokun:myasics bodhi$ ruby -Itest test/m_test.rb | |
Loaded suite test/m_test | |
Started | |
..E | |
Finished in 0.002001 seconds. | |
1) Error: | |
test_mock_should_fail(MTest): | |
Mocha::ExpectationError: unexpected invocation: #<Object:0x109c3fc30>.to_s() | |
unsatisfied expectations: |
Gems included by the bundle: | |
* abstract (1.0.0) | |
* actionmailer (3.0.0.beta3) | |
* actionpack (3.0.0.beta3) | |
* activemodel (3.0.0.beta3) | |
* activerecord (3.0.0.beta3) | |
* activeresource (3.0.0.beta3) | |
* activesupport (3.0.0.beta3) | |
* arel (0.3.3) | |
* builder (2.1.2) |
irb> x = [1,2,"",3, "", ""] | |
=> [1, 2, "", 3, "", ""] | |
irb> x.pop while x.last.blank? | |
=> nil | |
irb> x | |
=> [1, 2, "", 3] | |
irb> x = [1,2,"",3] | |
=> [1, 2, "", 3] |
class A | |
def a; "A#a" end | |
module B | |
def b; "B#b" end | |
end | |
include B | |
end |
(defun revert-buffer-with-sudo () | |
"reopen file in current buffer with sudo" | |
(interactive) | |
(let* ((filename (buffer-file-name (current-buffer))) | |
(sudo-filename (concat "/sudo::" filename))) | |
(kill-buffer) | |
(find-file sudo-filename))) |
Elixir's pipeline operator |>
apparently passes the result of each step as the first parameter to the next, so
iex> [1, [2], 3] |> List.flatten |> Enum.map(fn x -> x * 2 end)
[2, 4, 6]
is equivalent to
(letter spacing is only correct for non-bold text system setting)
// font: 11px / 13px; letter-spacing: 0.22px
// font: 12px / 16px; letter-spacing: 0.21px;
// font: 13px / 18px; letter-spacing: 0.2px
// font: 14px / 19px; letter-spacing: 0.17px; 0.1px @500
// font: 15px / 20px; letter-spacing: 0.13px; 0.063px @500
fizz = cycle [[], [], "fizz"] | |
buzz = cycle [[], [], [], [], "buzz"] | |
numbers = [1..] | |
fizzbuzz = zip3 fizz buzz numbers | |
toFizzBuzz [] [] x = show x | |
toFizzBuzz fizz buzz x = fizz ++ buzz |
Implementations of Happy Numbers
Simple recursive version that stores the previous steps in the sequence in an array, and checks for duplicates to detect cycles.
Can get up to 250,000,000 numbers in ~5s, with no memoisation:
$ time ./happy_numbers 350000000