>>5
You have not yet reached Satori. It's only syntaxic trickery. Here is a more honest version, in Common Lisp: (setf (symbol-function 'list%)
(lambda (&rest lambda) lambda))
>>6
No, I immediately understood why it work, but it still surprised me (it's not everyday that you see list defined as three lambdas surrounded by parentheses).
It's primitive computer algebra system I wrote a long time ago. It is only able to simplify nested sums and multiplications of variables.
A term is a number multiplied by a string of variables. In this case, the term
5 * x * y * z
is represented by the list:
(5 x y z)
The variables are kept in sorted order.
A linear combination is a sum of terms, and is represented as a list of terms. If a term has a zero coefficient, it is dropped from the linear combination. If a term's variables list has multiple occurrences in the linear combination, the terms with equal variables are combined into a single term where the coefficients are added together. Terms within a linear combination are sorted by their variables list.
Two linear combinations are added by merging them together.
Two linear combinations are multiplied by multiplying each pair wise term and then simplifying.
I never got to division.
Name:
Anonymous2012-07-24 3:36
>>15
>Implying LISP is slow, despite having JIT
>Probably codes in Python
IHBTBFIOC
I was depressive before we met
Now every bracket I see is a potential threat
And I'm possessive, it isn't nice
You've heard me saying that Python was my only vice
But now it isn't #t
Now everything is new
And all I've learned has overturned
I beg of you...
Don't go wasting computation
Lay all your sexp on me
It was like consing a sitting box
A little Smalltalk, a Scheme and baby I was stuck
I still don't know what you've done with me
A grown-up coder should never fall so easily
I feel a kind of fear
When I don't have you near
Unsatisfied, I skip my pride
I beg you dear...
Don't go wasting computation
Lay all your sexp on me
Don't go sharing your devotion
Lay all your sexp on me
I've had a few little C affairs
They didn't last very long and they've been pretty scarce
I used to think that I wasn't functional
It makes the #t even more incomprehensible
'cause everything is new
And everything is you
And all I've learned has overturned
What can I do...
Don't go wasting computation
Lay all your sexp on me
Don't go sharing your devotion
Lay all your sexp on me
They told you to forget Java and OOP.
They told you to read SICP and learn Lisp.
Now that you have reached satori the only things you can code are programs that check dubs.
Name:
Anonymous2012-07-24 21:51
>>34
There's are remainder and modulo procedures in vanilla Scheme.
If you can't be bothered to type that, then do at most something like (define % remainder).
Name:
Anonymous2012-07-24 22:14
>>37
Oh right, I didn't see that >>25 was defining it themselves instead of just using the one provided by the implementation.
#|
;; example usage:
(defun flatten (x)
(match x ((x . xs) (append (flatten x) (flatten xs)))
((x ! and x (atom x)) (list x))))
|#
Name:
Anonymous2013-08-13 7:44
>>45
And that code is now totally outdated, because most of the boilerplate gets implemented using Symta itself and in a simpler way. I.e. if one wants lazy lists or finger trees, he could just implement them and they would work like builtin lists.
Name:
Anonymous2013-08-13 13:09
(LAMBDA (A)
(DECLARE (OPTIMIZE (SPEED 3) (SAFETY 0) (DEBUG 0))
(TYPE FIXNUM A))
(LET ((REG (MAKE-ARRAY 256 :ELEMENT-TYPE 'FIXNUM :INITIAL-ELEMENT 0)))
(DECLARE (TYPE (SIMPLE-ARRAY FIXNUM (256)) REG)
(IGNORABLE REG))
(LABELS ((#:L980 (A #:R974 #:R975 #:R976 #:R977 #:R978 #:R979)
(DECLARE
(TYPE FIXNUM A #:R974 #:R975 #:R976 #:R977 #:R978 #:R979)
(IGNORABLE A #:R974 #:R975 #:R976 #:R977 #:R978 #:R979))
(#:L981 A A #:R975 #:R976 #:R977 #:R978 #:R979))
(#:L981 (A #:R974 #:R975 #:R976 #:R977 #:R978 #:R979)
(DECLARE
(TYPE FIXNUM A #:R974 #:R975 #:R976 #:R977 #:R978 #:R979)
(IGNORABLE A #:R974 #:R975 #:R976 #:R977 #:R978 #:R979))
(#:L982 A #:R974 A #:R976 #:R977 #:R978 #:R979))
(#:L982 (A #:R974 #:R975 #:R976 #:R977 #:R978 #:R979)
(DECLARE
(TYPE FIXNUM A #:R974 #:R975 #:R976 #:R977 #:R978 #:R979)
(IGNORABLE A #:R974 #:R975 #:R976 #:R977 #:R978 #:R979))
(#:L983 #:R974 #:R974 #:R975 #:R976 #:R977 #:R978 #:R979))
(#:L983 (A #:R974 #:R975 #:R976 #:R977 #:R978 #:R979)
(DECLARE
(TYPE FIXNUM A #:R974 #:R975 #:R976 #:R977 #:R978 #:R979)
(IGNORABLE A #:R974 #:R975 #:R976 #:R977 #:R978 #:R979))
(#:L984 (1- A) #:R974 #:R975 #:R976 #:R977 #:R978 #:R979))
(#:L984 (A #:R974 #:R975 #:R976 #:R977 #:R978 #:R979)
(DECLARE
(TYPE FIXNUM A #:R974 #:R975 #:R976 #:R977 #:R978 #:R979)
(IGNORABLE A #:R974 #:R975 #:R976 #:R977 #:R978 #:R979))
(#:L985 A A #:R975 #:R976 #:R977 #:R978 #:R979))
(#:L985 (A #:R974 #:R975 #:R976 #:R977 #:R978 #:R979)
(DECLARE
(TYPE FIXNUM A #:R974 #:R975 #:R976 #:R977 #:R978 #:R979)
(IGNORABLE A #:R974 #:R975 #:R976 #:R977 #:R978 #:R979))
(#:L986 #:R976 #:R974 #:R975 #:R976 #:R977 #:R978 #:R979))
(#:L986 (A #:R974 #:R975 #:R976 #:R977 #:R978 #:R979)
(DECLARE
(TYPE FIXNUM A #:R974 #:R975 #:R976 #:R977 #:R978 #:R979)
(IGNORABLE A #:R974 #:R975 #:R976 #:R977 #:R978 #:R979))
(#:L987 (+ A #:R975) #:R974 #:R975 #:R976 #:R977 #:R978 #:R979))
(#:L987 (A #:R974 #:R975 #:R976 #:R977 #:R978 #:R979)
(DECLARE
(TYPE FIXNUM A #:R974 #:R975 #:R976 #:R977 #:R978 #:R979)
(IGNORABLE A #:R974 #:R975 #:R976 #:R977 #:R978 #:R979))
(#:L988 A #:R974 #:R975 A #:R977 #:R978 #:R979))
(#:L988 (A #:R974 #:R975 #:R976 #:R977 #:R978 #:R979)
(DECLARE
(TYPE FIXNUM A #:R974 #:R975 #:R976 #:R977 #:R978 #:R979)
(IGNORABLE A #:R974 #:R975 #:R976 #:R977 #:R978 #:R979))
(#:L989 #:R974 #:R974 #:R975 #:R976 #:R977 #:R978 #:R979))
(#:L989 (A #:R974 #:R975 #:R976 #:R977 #:R978 #:R979)
(DECLARE
(TYPE FIXNUM A #:R974 #:R975 #:R976 #:R977 #:R978 #:R979)
(IGNORABLE A #:R974 #:R975 #:R976 #:R977 #:R978 #:R979))
(IF (ZEROP A)
(#:L990 A #:R974 #:R975 #:R976 #:R977 #:R978 #:R979)
(#:L983 A #:R974 #:R975 #:R976 #:R977 #:R978 #:R979)))
(#:L990 (A #:R974 #:R975 #:R976 #:R977 #:R978 #:R979)
(DECLARE
(TYPE FIXNUM A #:R974 #:R975 #:R976 #:R977 #:R978 #:R979)
(IGNORABLE A #:R974 #:R975 #:R976 #:R977 #:R978 #:R979))
(#:L991 #:R976 #:R974 #:R975 #:R976 #:R977 #:R978 #:R979))
(#:L991 (A #:R974 #:R975 #:R976 #:R977 #:R978 #:R979)
(DECLARE
(TYPE FIXNUM A #:R974 #:R975 #:R976 #:R977 #:R978 #:R979)
(IGNORABLE A #:R974 #:R975 #:R976 #:R977 #:R978 #:R979))
(:EXIT A #:R974 #:R975 #:R976 #:R977 #:R978 #:R979))
(:EXIT (A #:R974 #:R975 #:R976 #:R977 #:R978 #:R979)
(DECLARE (IGNORE #:R974 #:R975 #:R976 #:R977 #:R978 #:R979))
A))
(#:L980 A 0 0 0 0 0 0))))
Some generated code using labels and tail-calls rather than the tagbody/goto combination.
Name:
Anonymous2013-08-13 14:19
>>53 (SAFETY 0)
back to premature optimization, ``please!''
Name:
Anonymous2013-08-13 14:29
(DUBS (CHECK EM))
Name:
Anonymous2013-08-13 15:17
>>54
without (SAFETY 0) you wouldn't have been born
Name:
Anonymous2013-08-13 19:02
>>54
It's not premature optimization, as this was the final step in optimizing the program.