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

Pages: 1-

LISP ZIPPERS

Name: Anonymous 2013-01-17 2:23

Integrating zippers into the very core of Lisp as a replacement/enhancement of cons lists.

Discuss.

Name: Anonymous 2013-01-17 3:13

I would like to contribute to this thread but I don't know what a zipper is.

Name: Anonymous 2013-01-17 3:29

>>1
You can have zippers as pairs of lists right now, and defmacro whatever facilities you want to have with them.  No lisp would take them as the core concept because while they are often useful, in most cases plain old lists are just fine.

>>2
It is what you unzip to take a pee

Name: Anonymous 2013-01-17 3:38

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

>>2
It is a purely functional transformation of a data structure that allows easy and efficient navigation.

For example, a (cons) list zipper of the list (0 1 2 3 4) focused at position 3 could be represented as ((2 1 0) . (3 4)). As you can see, you can travel both forwards and backwards in the list in O(1), e.g. to travel backwards, you would remove the 2 in the first position of the first list and insert it as the first element of the second list.

You can also have tree zippers (which would have an 'up' navigation function instead of just 'left-child' and 'right-child'), as well as for pretty much any kind of data structure.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iF4EAREKAAYFAlD3uGkACgkQGRQwWY30ng2pAQD/d0Fb7+RUV17mqLxrrnBjI9JO
4Jzde7lUDstEGYoJaW0A/i9R7oJ326vqyCzRrinM6DNtKcYZz+BBii2Xi4xwQ59z
=t48V
-----END PGP SIGNATURE-----

Name: Anonymous 2013-01-17 3:45

>>3
No lisp would take them as the core concept because while they are often useful, in most cases plain old lists are just fine.
Why not have "plain old lists" as a specific case of zipper lists?

Name: Anonymous 2013-01-17 3:47

>>4
That's pretty kewl. Couldn't you just use a doubly linked list or something though?

Name: Anonymous 2013-01-17 4:04

>>4
Better idea would be integrating concatenating queues, like finger trees.

Name: Anonymous 2013-01-17 4:21

That's neat. A much needed addition to my spell book.


(library (my-sheiit zippers)
  (export make-zipper zipper zup-list zdown-list zdown zup zdown-null? zup-null? zup-car zdown-car)
  (import (rnrs))

  (define (make-zipper behind forward)
    (cons behind forward))

  (define (zipper . lis)
    (make-zipper '() lis))

  (define zup-list car)

  (define zdown-list cdr)

  (define (zup-null? z)
    (null? (zup-list z)))

  (define (zdown-null? z)
    (null? (zdown-list z)))

  (define (zup-car z)
    (assert (not (zup-null? z)))
    (car (zup-list z)))

  (define (zdown-car z)
    (assert (not (zdown-null? z)))
    (car (zdown-list z)))

  (define (zup z)
    (assert (not (zup-null? z)))
    (make-zipper (cdr (zup-list z))
                 (cons (zup-car z) (zdown-list z))))

  (define (zdown z)
    (assert (not (zdown-null? z)))
    (make-zipper (cons (zdown-car z) (zup-list z))
                 (cdr (zdown-list z)))))

Name: Anonymous 2013-01-17 4:43

Name: Anonymous 2013-01-17 6:32

>>8
(define (zipper-ref z n)
 (define (zref-aux z n proc)
  (if (zero? n) z
   (zref-aux (proc z) (- n 1) proc)))
 (zref-aux z (abs n)
  (if (negative? n) zup zdown)))

Name: Anonymous 2013-01-17 6:55

Hash tables should be the the data type, really.

Name: Anonymous 2013-01-17 14:20

Actually, the FAQ uses a scarier example, which launches nuclear missiles as the result of the mistake. IMHO, nothing can beat the following classic in this department:

if(status = UNDER_ATTACK) {
  launch_nuclear_missiles();
}

Name: Anonymous 2013-01-17 16:20

ZIP LISPPERS

Name: Anonymous 2013-01-17 18:34

>>12 yeah that will happen everytime since you're setting status. check for equivalence instead, goyim

Name: Anonymous 2013-01-17 18:50

>>14
Only if UNDER_ATTACK != 0.

Name: Anonymous 2013-01-17 22:55

>>12
That's terrifying. It's bad enough that they exist, then worse that they are computer controlled, and then terrifying when they are controlled with c. But then again, if a nuke is fired, doesn't it really matter if it was intentional or if it was an accident?

Name: Anonymous 2013-01-18 3:04

>>16
The only winning move is not to use C or C++.

Name: Anonymous 2013-01-18 3:53

Lisp should support the following data structures natively and support special syntax for each of them:

Lists.
Fixed length arrays.
Variable length arrays with amortized growth.
Doubly linked lists.
Hash sets
Hash maps
Sorted sets
Sorted maps
Queues
Zippers
Ring buffers
Priority queues
Graphs, encoding and decoding of cyclic structures

And each data structure should have a smorgasborg of library functions, with each one implemented in native code.

Name: Anonymous 2013-01-18 4:33

Zip lispers

Name: Anonymous 2013-01-18 6:18

>>17
wargames

Name: Anonymous 2013-01-18 6:23

>>20
Stop labeling data for the popular culture reference inference engine you faggot.

Name: Anonymous 2013-01-18 6:30

>>21
Are you anti-Semite? Because every mention of a Hollywood movie serves as an advertisement and makes money for the Jewish community.

Name: Anonymous 2013-01-18 6:57

>>22
Back to the I-Love-Hitler-Fan-Club with you.

Name: Anonymous 2013-01-18 7:04

>>23
So why hollywood, instead of some indie production, which really needs publicity?

Name: Anonymous 2013-01-18 7:04

>>22
Back to the I-Love-Hitler-Fan-Club with you.

Name: Anonymous 2013-01-18 7:15

>>25
Shalom!

Name: Anonymous 2013-01-18 8:05

>>24
Do not try to use sensible arguments with Jews, it's useless.

Name: Anonymous 2013-01-18 8:10

So is this thread like an RSA implementation in lisp?

>>18
check Common Lisp. All your examples have already been implemented into macros.
Lists[o]
Fixed length arrays (constant list)[o]
Variable length arrays with amortized growth (lambda list)[o]
Doubly linked lists (are you just starting databases design?)[o]
Hash sets (functions, like RSA. lambdas are quicker)[o]
Hash maps (see above, and make lists)[o]
Sorted sets (lambda lists on a loop...)[o]
Sorted maps (see above, just make a list)[o]
Queues (... are you learning pgsql just now? time and list)[o]
Zippers (see RSA)[o]
Ring buffers (while loop)[o]
Priority queues (see above)
Graphs, encoding and decoding of cyclic structures (lists and any "graphical" output (I read cairo is pretty awesome), lambdas)

Name: Anonymous 2013-01-18 8:33

>>28
What does a popular public key cryptographic algorithm have to do with Common Lisp?

Name: Anonymous 2013-01-18 8:43

>>29 merging lists of value with functions: hashing.

Name: Anonymous 2013-01-18 22:07

bumpaya~

Name: Anonymous 2013-01-18 23:34

>>28
IHBT

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