Skip to content

Commit aaae5e9

Browse files
committed
Changed logo, made symbol allow numbers, added to examples
1 parent 17bb529 commit aaae5e9

File tree

5 files changed

+31
-6
lines changed

5 files changed

+31
-6
lines changed

assets/logo.png

-458 KB
Loading

examples/io.lisp

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
(defun clear () (do (map (lambda (_) (print "")) (range 0 100)) @))
22
(define cls clear)
33

4-
"success"
4+
(cls)
5+
6+
(print "success")

examples/list.lisp

+26-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
(defun repeat (x count) (map (lambda (_) x) (range 0 count)))
1+
; (defun repeat (x count) (map (lambda (_) x) (range 0 count)))
22
(defun len (l) (reduce (lambda (acc _) (+ acc 1)) 0 l))
33

44
; get the nth item in a list
@@ -23,13 +23,28 @@
2323
(range 0 size)
2424
))
2525

26+
; (defun median-of-three (l)
27+
; (if (>= (len l) 3)
28+
; (do (define n1 (first l))
29+
; (define n2 (index l (/ (len n) 2)))
30+
; (define n3 (last l))
31+
; (if (* (<= n2 n1) (<= n1 n3)) n1
32+
; (* (<= n1 n2) (<= n2 n3)) n2
33+
; n3))
34+
; (first l)))
35+
36+
(defun median-of-three (l)
37+
(if (>= (len l) 3)
38+
(min (max (first l) (index l (/ (len l) 2))) (last l))
39+
(first l)))
2640

2741
; quicksort a list
2842
(defun qs (l)
2943
(if (<= (len l) 1)
3044
l
3145
(do
32-
(define pivot (first l))
46+
; (define pivot (first l))
47+
(define pivot (median-of-three l))
3348
(+
3449
(qs (filter (lambda (n) (> pivot n)) l))
3550
(list pivot)
@@ -91,5 +106,13 @@
91106
)
92107
)
93108
))
109+
110+
111+
(define list-to-sort (random-list 0 100 100))
112+
113+
(print "Unsorted list: " list-to-sort)
114+
(print "Merge-sorted list: " (merge-sort list-to-sort))
115+
(print "Quick-sorted list: " (qs list-to-sort))
116+
94117
; this is too!
95-
"success"
118+
"success"

examples/math.lisp

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@
3434
(collatz (/ n 2))
3535
)))
3636

37-
"success"
37+
"success"

wisp.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ void replace_substring(std::string &src, std::string substr, std::string replace
113113

114114
// Is this character a valid lisp symbol character
115115
bool is_symbol(char ch) {
116-
return (isalpha(ch) || ispunct(ch)) && ch != '(' && ch != ')' && ch != '"' && ch != '\'';
116+
return (isalnum(ch) || ispunct(ch)) && ch != '(' && ch != ')' && ch != '"' && ch != '\'';
117117
}
118118

119119
////////////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)