Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-4041-

Post Lisp Code

Name: Anonymous 2012-07-23 3:49

JUST POST SOME FUCK ING LISP!!!!

(defun generate-expr (&key fn-list term-list max-depth method)
  (if (or (= max-depth 0)
      (and (eq method :grow)
           (< (random 1.0)
          (/ (length term-list) (+ (length term-list) (length fn-list))))))
      (nth (random (length term-list)) term-list)
      (let* ((fn (nth (random (length fn-list)) fn-list))
         (arity (length `(swank-backend:arglist ,fn))))
    (cons fn (loop for i from 0 to arity
         collect (generate-expr :fn-list fn-list :term-list term-list :max-depth (1- max-depth) :method method))))))

Name: Anonymous 2012-07-23 3:58

(define (uniq l)
  (uniq/acc l '()))
(define (uniq/acc l acc)
  (if (null? l)
      (reverse acc)
      (let ((e (car l)))
        (uniq/acc
         (filter (lambda (x)
                   (not (equal? x e)))
                 (cdr l))
         (cons e acc)))))

Name: Anonymous 2012-07-23 4:31

(call/cc call/cc)

Name: Anonymous 2012-07-23 4:35

(define list (lambda lambda lambda))

Name: >>3 2012-07-23 4:40

>>4
> (blown? mind)
#t

Name: Anonymous 2012-07-23 5:02

>>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))

Name: Anonymous 2012-07-23 5:06

>>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).

Name: >>7 2012-07-23 5:06

*works

Name: Anonymous 2012-07-23 15:07


(    λ
    λ λ
   λ   λ
  λ λ λ λ )

Name: Anonymous 2012-07-23 16:03

If I simply read SICP, will I reach Satori? I believe SICP is a Scheme book

Name: Anonymous 2012-07-23 18:39

New fags can't dubsforce

Name: Anonymous 2012-07-23 18:51


( λλ
    λ
     λ
    λ λ
  λλ   λλ )

Name: Anonymous 2012-07-23 19:36

8=D

Name: Anonymous 2012-07-23 22:58


λλλ LISPs do their best now and are preparing. λλλ
λλλ    Please wait warmly until it is ready.   λλλ

Name: Anonymous 2012-07-24 0:14

>>14
>best now
they barely run without overheating the PC

Name: Anonymous 2012-07-24 0:24

Name: Anonymous 2012-07-24 0:26

>>15
If it ain't Lisp, it's crap.

Name: Anonymous 2012-07-24 0:28

>>17
If it ain't shit, it's crap.

>>16
Get with the times, gramps: http://en.wikipedia.org/wiki/Loongson#Loongson_3

Name: Anonymous 2012-07-24 0:31


;; a linear-combination is a list of terms, sorted by term<?

(def (linear-combination-to-normal-form l)
  (filter (lambda (t1) (not (eq? (term-scalar t1) 0)))
          (merge-sort-uniq term<? term=? combine-terms l)))

(def (linear-combination-sum l1 l2)
  (filter (lambda (t1) (not (eq? 0 (term-scalar t1))))
          (merge-uniq term<? term=? combine-terms l1 l2)))

(def (linear-combination-product l1 l2)
  (evenly-reduce linear-combination-sum
                 (map (lambda (l1-term)
                        (linear-combination-to-normal-form
                          (map (lambda (l2-term)
                                 (multiply-terms l1-term l2-term))
                               l2)))
                      l1)))

(def (linear-combination-invert l)
  (map (lambda (current-term)
         (term (- (term-scalar current-term))
               (term-product-list current-term)))
       l))

;; nested sums will remain in the product.
(def (product->term args)
  (letrec ((helper (lambda (args accumulation-scalar accumulation-product-list)
             (cond ((null? args) (cond ((null? accumulation-product-list) (number->term accumulation-scalar))
                                       (else (term accumulation-scalar (merge-sort expr<? accumulation-product-list)))))
                   ((number? (car args)) (helper (cdr args)
                                                 (* accumulation-scalar (car args))
                                                 accumulation-product-list))
                   (else (helper (cdr args) accumulation-scalar (cons (car args) accumulation-product-list)))))))
    (helper args 1 '())))

(def (product->linear-combination args)
  (evenly-reduce linear-combination-product (map expr->linear-combination args)))

(def (number->term num)
  (term num '()))

(def (symbol->term symbol)
  (term 1 (list symbol)))

(def (sum->linear-combination args)
  (evenly-reduce linear-combination-sum (map expr->linear-combination args)))

(def (expr->linear-combination e)
  (cond ((number? e) (list (number->term e)))
        ((symbol? e) (list (symbol->term e)))
        ((list? e) (cond ((null? e) '())
                         ((eq? (car e) '*) (product->linear-combination (cdr e)))
                         ((eq? (car e) '+) (sum->linear-combination (cdr e)))
                         ((eq? (car e) '-) (linear-combination-invert (expr->linear-combination (cadr e))))))))

Name: Anonymous 2012-07-24 0:32

>>15
lol u mad that lisp still exists, faget
so mad
so buttravaged

Name: Anonymous 2012-07-24 0:57

(def (ancient->language)
  (just_use_java)
    (lel++) (oh wait you probably can't even do that)
)

Name: Anonymous 2012-07-24 1:12

>>21
Quit spamming your shitty DSL here.

Name: Anonymous 2012-07-24 1:25

(defun starts here)

Name: Anonymous 2012-07-24 2:21

>>19
Would you care to explain your code?  What are terms?

Name: Anonymous 2012-07-24 2:35

(define (dubs em)
  (define (check them)
    (= (% them 10)
       (/ (% (- them (% them 10)) 100) 10)))
   (check em))

(define (% a b) (cond ((< (- a b) 0) a)
  (else (% (- a b) b))))

(dubs 122)
;Value: #t
(% 122 11)
;Value: 1


Using %11 doesn't work past numbers with value > 100 whereas this will.

Trips checker written in reference to the dubs checker.

(define (trips em)
  (cond ((dubs em) (dubs (/ (- em (% em 10)) 10)))
        (else #f)))

(trips 323)
;Value: #f
(trips 333)
;Value: #t

Name: Anonymous 2012-07-24 2:58

>>24

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: Anonymous 2012-07-24 3:36

>>15
>Implying LISP is slow, despite having JIT
>Probably codes in Python
IHBTBFIOC

Name: Anonymous 2012-07-24 3:42

>>27
NYJMUA

Name: LISPPER 2012-07-24 4:02

ABBA - Lay All Your Sexp On Me

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

Name: Anonymous 2012-07-24 4:58

>>27
Why are you putting a greater than sign before incomplete sentences?

Name: Anonymous 2012-07-24 16:07

>>25
Why the hell are you defining %? And in such an non-optimal way?
You haven't read SICP, have you?

Name: Anonymous 2012-07-24 16:26

>>31
No one cares to define expmod.

Name: Anonymous 2012-07-24 18:51

GC just kicked in, yo!

Name: Anonymous 2012-07-24 21:01

>>31
Dude, modulus is pretty long to type.

Name: Anonymous 2012-07-24 21:33

>>25
Terrible!

(defun dubsp (n)
  (= (mod (mod n 100) 11) 0))

Name: Anonymous 2012-07-24 21:45

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: Anonymous 2012-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: Anonymous 2012-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.

Name: Anonymous 2012-07-24 23:33

>>29
More of this, please.

Name: Anonymous 2012-07-27 15:12

(defun binomial-coefficient (k n)
  "Compute the binomial coefficient indexed by K and N."
  (declare (type unsigned-byte k n))
  (let ((memo (make-array n
                          :element-type 'hash-table
                          :initial-contents
                          (loop repeat n
                             collect (make-hash-table :test 'eql :size k)))))
    (labels ((meat (k n)
               (declare (type unsigned-byte k n))
               (cond ((or (= k n)
                          (zerop k)) 1)
                     ((or (= k 1)
                          (= (1- k) n)) n)
                     ((> k n) 0)
                     ((> k (ceiling n 2))
                      (rec (- n k) n))
                     (t
                      (+ (rec k (1- n))
                         (rec (1- k) (1- n))))))
             (rec (k n)
               (declare (type unsigned-byte k n))
               (cond ((or (= k n)
                          (zerop k)) 1)
                     ((or (= k 1)
                          (= (1- k) n)) n)
                     ((> k n) 0)
                     (t
                      (let ((htbl (aref memo k))
                            (key n))
                        (or (gethash key htbl)
                            (setf (gethash key htbl)
                                  (meat k n))))))))
      (rec k n))))

Name: Anonymous 2012-07-27 16:00

(setq faggot 'you)

Name: Anonymous 2012-07-27 16:15

check this

Name: Anonymous 2013-02-17 2:34

Name: Anonymous 2013-02-17 8:25

smack 'em

Name: Anonymous 2013-02-17 9:45

Post Lisp Code

Here is some code from newest Symta:

  (let* ((xs (filter-keywords nil nil ls))
         (ks (car xs))
         (ls (cdr xs))
         (a (unisym))
         (ms (make-hash-table :test 'equal))
         (mm nil))
    ($map (fn (l)
            (let ((hd (lhd (lhd l))))
              (if (fn-sym? hd)
                  (setf l (st ($(ltl (lhd l)) $$(ltl l))))
                  (setf hd "_"))
              (setf (gethash hd ms)
                    (st ($$(gethash hd ms)
                           $(st ((|[]| $(lhd l)) $$(ltl l))))))))
          ls)
    (maphash (fn (hd ls)
               (let* ((x (chain-lambs a ls nil))
                      (*checked-lst-method* (not (string= hd "_")))
                      (y (when *checked-lst-method* (chain-lambs a ls nil))))
                 (setf (gethash hd ms) (cons y x))))
             ms)
    (setf mm (car (gethash "_" ms)))
    (remhash "_" ms)
    (unless (= (hash-table-count ms) 0)
      (let* ((d (unisym))
             (h (unisym))
             (vs nil))
        (maphash (fn (k v) (setf vs (st (($k $(car v) (_fn ($a) $(cdr v))) $$vs))))
                 ms)
        (setf mm
              (st (_let (($d nil) $$($map (fn (v) (lst (lhd v) nil)) vs))
                    (do (set_l $d (_fn () $mm))
                        $$($map (fn (v) (st (set_l $(1st v) $(3rd v)))) vs)
                        (_let (($h (cl (aref $a 0))))
                           (_if (cl (stringp $h))
                                $(search-method h ($map #'rtl vs) d)
                                (c $d)))))))
        ))
    (when name (setf mm (st (cl (block $name ($"@" $mm))))))
    (st (_fn ($a $$(if ks (lst ks))) $mm)))

Name: Anonymous 2013-02-17 10:12

Wow, this thread is so not post-lisp.  I am disappointed.

Name: Anonymous 2013-02-17 10:46

>>14
LISP 0666: The Embodiment of Lambda Knight

Name: Anonymous 2013-02-17 11:36

check 'em

Name: Anonymous 2013-02-17 12:17

No

Name: Anonymous 2013-08-13 5:09

>>29
Come back to /prog/, please ;_;

Name: Anonymous 2013-08-13 7:41

Updated version of my match macro, which I'm using for Symta:

(defun includes (v xs)
  (when (consp xs)
    (or (eql (car xs) v)
        (includes v (cdr xs)))))

(defun match-hole (key hole hit miss)
  (unless (consp hole)
    (return-from match-hole
      (if (and hole (symbolp hole) (not (keywordp hole)) (not (eql hole t)))
          (if (string= (symbol-name hole) "_")
              hit
              `(let ((,hole ,key))
                 ,hit))
          `(if (equal ',hole ,key)
               ,hit
               ,miss))))
  (when (eql (car hole) '=)
    (return-from match-hole
       (match-hole key (second hole) (match-hole key (third hole) hit miss) miss)))
  (when (eql (car hole) 'or)
    (return-from match-hole
      `(if (match ,key ,@(mapcar (lambda (x) `(,x t)) (cdr hole)))
           ,hit
           ,miss)))
  (when (eql (car hole) 'not)
    (return-from match-hole
      `(if (match ,key ,@(mapcar (lambda (x) `(,x t)) (cdr hole)))
           ,miss
           ,hit)))
  (when (eql (car hole) '/)
    (return-from match-hole
      (let ((g (gensym)))
        `(let ((,g (,(second hole) ,key)))
           ,(match-hole g (third hole) hit miss)))))
  (when (includes '! hole)
    (let ((xs (split '! hole)))
      (return-from match-hole
        `(let ((,@(car xs) ,key))
           (if ,(!body (cdr xs))
               ,hit
               ,miss)))))
  (when (and (eql (car hole) 'quote)
             (= (length hole) 2))
    (return-from match-hole
      `(if (equal ,(second hole) ,key)
           ,hit
           ,miss)))
  (let ((x (gensym))
        (hit (match-hole key (cdr hole) hit miss)))
    `(if (consp ,key)
         (let ((,x (car ,key))
               (,key (cdr ,key)))
           ,(match-hole x (car hole) hit miss))
         ,miss)))

(defmacro match (keyform &body cases)
  (let ((key (gensym))
        (b (gensym)))
    `(let ((,key ,keyform))
       (block ,b
         (tagbody
           ,@(reduce (lambda (next case)
                       (let ((miss (gensym))
                             (hit `(return-from ,b (progn ,@(cdr case)))))
                         `(,(match-hole key (car case) hit `(go ,miss)) ,miss ,@next)))
                     (cons nil (nreverse cases))))))))

#|
;; example usage:
(defun flatten (x)
  (match x ((x . xs) (append (flatten x) (flatten xs)))
           ((x ! and x (atom x)) (list x))))
|#

Name: Anonymous 2013-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: Anonymous 2013-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: Anonymous 2013-08-13 14:19

>>53
(SAFETY 0)
back to premature optimization, ``please!''

Name: Anonymous 2013-08-13 14:29

(DUBS (CHECK EM))

Name: Anonymous 2013-08-13 15:17

>>54
without (SAFETY 0) you wouldn't have been born

Name: Anonymous 2013-08-13 19:02

>>54
It's not premature optimization, as this was the final step in optimizing the program.

Name: Anonymous 2013-08-13 19:03

>>57
edit: After it was already correct

Don't change these.
Name: Email:
Entire Thread Thread List