Open up Terminal.app
in your /Applications/Utilities
directory, then type in these commands, one after each other:
-
Create a temporary directory for cycript:
mkdir cycript && cd cycript
-
Pull the latest cycript from cycript.org:
=begin | |
Pentagonal numbers are generated by the formula, Pn=n(3n−1)/2. The first ten pentagonal numbers are: | |
1, 5, 12, 22, 35, 51, 70, 92, 117, 145, ... | |
It can be seen that P^4 + P^7 = 22 + 70 = 92 = P^8. | |
However, their difference, 70 − 22 = 48, is not pentagonal. | |
Find a pair of pentagonal numbers P^j and P^k, |
import Either | |
--main = asText (filterrr (\x -> x > 2) [1, 2, 3, 4]) | |
main = asText (map squirtWithError [-2, -1, 0, 16, 36]) | |
-- types | |
data Option a = None | Some a |
=begin | |
If the numbers 1 to 5 are written out in words: one, two, three, four, five, then there are 3 + 3 + 5 + 4 + 4 = 19 letters used in total. | |
If all the numbers from 1 to 1000 (one thousand) inclusive were written out in words, how many letters would be used? | |
NOTE: Do not count spaces or hyphens. For example, 342 (three hundred and forty-two) contains 23 letters and 115 (one hundred and fifteen) contains 20 letters. The use of "and" when writing out numbers is in compliance with British usage. | |
=end | |
# "and" COUNTS! |
class String | |
def palindrome? | |
self == self.reverse | |
end | |
end | |
class Integer | |
def palindrome?(b=10) | |
self.to_s(b).palindrome? | |
end |
# proccc | |
def one proccc, x | |
proccc.(x) | |
end | |
def two proccc, x | |
proccc.(proccc.(x)) | |
end |
class Fixnum | |
def ordinal | |
%w[first second third fourth fifth sixth seventh eighth ninth tenth eleventh twelfth][self - 1] | |
end | |
# Use #to_word rather than #to_s, so it doesn't break any other printing of numbers. | |
def to_word | |
%w[one two three four five six seven eight nine ten eleven twelve][self - 1] | |
end | |
end |
$array = [] | |
module Collatz | |
def self.how_many n | |
if n == 1 | |
($array.push n).length | |
elsif n.even? | |
$array.push n | |
n = n / 2 | |
how_many n |
(define menu | |
(lambda (x y) | |
(conde | |
[(== x 'tea) (== y 'biscuit)] | |
[(== x 'coffee) (== y 'cookie)]))) | |
(define conso | |
(lambda (x y o) | |
(== `(,x . ,y) o))) |
(ns hs-js-clj.core) | |
(def foo {:bar 1}) | |
(defn fooify [n] (str "foo" n)) | |
(defn commaify [[x y]] | |
(str x ", " y)) |