Skip to content

Instantly share code, notes, and snippets.

@kuribas
Last active June 25, 2018 09:24
Show Gist options
  • Save kuribas/7f25bfb1c365bece99e2b359d738b97d to your computer and use it in GitHub Desktop.
Save kuribas/7f25bfb1c365bece99e2b359d738b97d to your computer and use it in GitHub Desktop.
triangle
triangle = map (\i -> [(i * (i-1) `quot` 2) + 1 ..
(i * (i+1) `quot` 2)])
[1..]
(defun triangle (rows)
(mapcar
(lambda (row)
(iota row (+ 1 (/ (* row (- row 1)) 2))))
(iota rows 1)))
(defun iota (cnt &optional (start 0) (step 1))
(if (= cnt 0) '()
(cons start (iota (- cnt 1) (+ start step)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment