# project-euler

committed 93a230b

Compensate for moving those functions into libraries.

# Scheme/102.scm

`-;; For a triangle to contain the origin, the following must be true: for each`
`-;; point, a line connecting it and the origin must pass through the line`
`-;; segment which connects the other two points.  Now we just need to figure out`
`-;; how to determine if a line and a line segment intersect.`
`-;;`
`-;; Finding the intersection of a line with a line segment is easy enough.`
`-;; First we use the coordinates of the line segment to bound an area wherein`
`-;; the intersection must occur.  Next we find the intersection by treating the`
`-;; line segment as an infinite line (there's a quick way to do this).  Since`
`-;; lines can only intersect at most one time, we check the result to see if`
`-;; it's inside the box.  If it is, then the line and line segment intersect,`
`-;; otherwise the answer is that they do not intersect.`
`-`
`-(define line-intersect`
`-  (lambda (l1 l2)`
`-    (let ((p1 (car l1))`
`-          (p2 (cadr l1))`
`-          (p3 (car l2))`
`-          (p4 (cadr l2)))`
`-      (let ((x1 (car p1))`
`-            (y1 (cadr p1))`
`-            (x2 (car p2))`
`-            (y2 (cadr p2)))`
`-        (let ((x3 (car p3))`
`-              (y3 (cadr p3))`
`-              (x4 (car p4))`
`-              (y4 (cadr p4)))`
`-          (list (/ (- (* (- (* x1 y2) (* y1 x2)) (- x3 x4))`
`-                      (* (- x1 x2) (- (* x3 y4) (* y3 x4))))`
`-                   (- (* (- x1 x2) (- y3 y4))`
`-                      (* (- y1 y2) (- x3 x4))))`
`-                (/ (- (* (- (* x1 y2) (* y1 x2)) (- y3 y4))`
`-                      (* (- y1 y2) (- (* x3 y4) (* y3 x4))))`
`-                   (- (* (- x1 x2) (- y3 y4))`
`-                      (* (- y1 y2) (- x3 x4))))))))))`
`-`
`-(define %substring`
`-  (lambda args`
`-    (if (= (length args) 2)`
`-      (substring (car args) (cadr args) (string-length (car args)))`
`-      (apply substring args))))`
`-`
`-(define string-index`
`-  (lambda (s c)`
`-    (call/cc (lambda (k)`
`-               (let search ((i 0))`
`-                 (if (>= i (string-length s))`
`-                   (k #f)`
`-                   (if (char=? (string-ref s i) c)`
`-                     (k i)`
`-                     (search (+ i 1)))))))))`
`-`
`-(define string-split`
`-  (lambda (s c)`
`-    (let loop ((result '()) (s s))`
`-      (let ((index (string-index s c)))`
`-        (if index`
`-          (loop (cons (%substring s 0 index) result)`
`-                (%substring s (+ index 1)))`
`-          (reverse (cons s result)))))))`
`+(tcv-require '(geometry io list))`
` `
` (define list-gather`
`   (lambda (l n)`
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.