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

Pages: 1-

FBS vs DABS

Name: Anonymous 2009-08-30 15:07

Which do you prefer?
Fibonacci Butt Sort
or
Directed Acyclic Butt Sort

Name: Anonymous 2009-08-30 15:09

Hree/Treap sorting.

Name: Anonymous 2009-08-30 15:11

I like DABS better because it's more legible and better supported by shiichan. Why you ask? Because Shiichan has a tag limit and DABS uses far less tags.

Name: Anonymous 2009-08-30 15:31

Requesting binary dicks tree.

Name: Anonymous 2009-08-30 15:50

Balanced Binary Dick Tree

Name: Anonymous 2009-08-30 17:07

I just buttsorted a Binary Dicks Tree. Here is the result:

[b][i] dicks / [o][/o] / [o][/o] dicks dicks / [o][/o] / [o][/o] / * / [o][/o] dicks dicks dicks / [u][/u] / [u][/u] / [u][/u] * dicks * * * dicks[/i][/b]

Name: Anonymous 2009-08-30 17:10

>>6
Next time listen to the warnings your BBcode compiler spits out.

Name: Anonymous 2009-08-30 17:17

>>6
>>7
MY GOSH IM STILL LOLING WHY IS THIS SOO FUNNY?

Name: Anonymous 2009-08-30 17:58

The pleasure of being cummed inside.

Name: Anonymous 2009-08-30 20:03

Acyclic
One day I'm going to stop seeing Acrylic instead of Acyclic ;_;

Name: Anonymous 2009-08-30 23:36

[b][i] [o][/o] dicks / / dicks dicks / / / * / dicks dicks dicks / / / * dicks * * * dicks[/i][/b]

Name: Anonymous 2009-08-30 23:38

2-in-1 implementation of Fibonacci Butt Sort and Directed Acyclic Butt Sort :


(asdf:oos 'asdf:load-op '#:split-sequence)

(defun wrap-tag (string tag)
  (if (null tag)
      ""
      (format nil "[~a]~a[/~a]" tag string tag)))

(defun wrap-tags (string &rest tags)
  (labels ((rec (string tags)
             (if tags
                 (rec (wrap-tag string (car tags)) (cdr tags))
                 string)))
    (rec string (reverse tags))))

(defun split-string (s)
  (loop for c across s collect c))

(defun bbsort (s &optional acyclic)
  (let ((seqs (if acyclic
                  (mapcan #'(lambda (x) (list x #\Space)) (split-sequence:split-sequence #\Space s))
                  (split-string s)))
        parity)
    (wrap-tags
      (apply #'concatenate 'string
             (mapcar #'(lambda (x)                        
                         (if (member x '(#\  "" " ") :test #'equal)
                             " "
                             (progn
                               (setf parity (not parity))
                               (wrap-tag x (if parity "o" "u")))))
                     seqs)) "i" "b")))

Name: Anonymous 2009-08-30 23:47

>>12
Not bad! This makes me want to finally bite the bullet and learn functional programming. Is this a mistake?

Name: Anonymous 2009-08-30 23:50

>>13
The code isn't purely functional as I used a SETF once (could have easily avoided that, but at the cost of some slight performance loss).

Is this a mistake?
No, programming is fun again.

Name: Anonymous 2009-08-30 23:52

>>14
You also used LOOP.

Name: Anonymous 2009-08-30 23:54

>>13
Yes. Functional programming is purely theoretical.

I wanted to troll you, but I also want to troll the rest of /prog/, so I'll also help you. Look at it this way: On the scale of low level vs. high level languages, every step up from assembly takes you further away from imperative programming, and closer to functional programming. Even Fortran, the lowest-level high level language, was originally popular because it let you write mathematical expressions without having to store the intermediate values in temporary variables. Functional programming just means applying that idea to the rest of your program. Anyway, go learn Haskell.

Name: Anonymous 2009-08-30 23:56

>>15
I don't think there's a rule saying that that specific LOOP expands to side-effecting code. In reality even tail recursive calls are optimized(with apropriate optimization declarations for CL, and mandatory for Scheme) into imperative loops, so the point is moot.

Name: Anonymous 2009-08-31 0:05

I wanted to troll you, but I also want to troll the rest of /prog/, so I'll also help you

enterprise scalable trolling

Name: Anonymous 2009-08-31 0:54

Fibonacci Butt Sort by Anal Touring

Name: Anonymous 2009-08-31 0:58

import Data.List; import Control.Monad.State;

tag t str = "[" ++ t ++ "]" ++ str ++ "[/" ++ t ++ "]"
[b,i,o,u] = tag `map` words "b i o u"

dabs = b . i . unwords . zipWith id (cycle [o,u]) . words
fbs = b . i . concat . flip evalState (cycle [o,u]) . mapM f where
    f ' ' = return " "
    f c = (liftM . concatMap) ($ [c]) (State $ splitAt 1)


It's not a 2-in-1, but it is quite short.

Name: Anonymous 2009-08-31 1:06

>>17
Not moot at all! Loop is only for disgusting imperative programmers and it's unlispy too! Any program containing loop (or using the symbol in any way) is inherently unclean!

Name: Anonymous 2009-08-31 1:33

>>21

(defun split-string (s)
  (map 'vector #'identity s))


PROGN and SETF could also be removed by adding a (cycle t nil) (cycle can be found on /prog/, it was posted a few days ago) and rewriting the code around that MAP a bit. The point still stands that LOOP will usually be more efficient than the equivalent MAP in this case, of course this is implementation dependent.

Name: Anonymous 2009-08-31 1:36

Oops, I meant to say:

(defun split-string (s)
  (map 'list #'identity s))

Name: Anonymous 2009-08-31 1:45

Hmm, performance cost isn't too large:

MAP version:

CL-USER> (time-test 1000000 (split-string2 "ABC"))
Evaluation took:
  0.094 seconds of real time
  0.093750 seconds of total run time (0.093750 user, 0.000000 system)
  100.00% CPU
  238,621,410 processor cycles
  24,001,080 bytes consed


LOOP version:

CL-USER> (time-test 1000000 (split-string "ABC"))
Evaluation took:
  0.062 seconds of real time
  0.062500 seconds of total run time (0.062500 user, 0.000000 system)
  [ Run times consist of 0.016 seconds GC time, and 0.047 seconds non-GC time. ]
  100.00% CPU
  180,198,549 processor cycles
  31,999,776 bytes consed


It seems LOOP version conses more, but is faster, while MAP version conses less, but is slower by a bit. Implementation used was SBCL. [oode]TIME-TEST[/code] is just a macro which executes a form a given number of times (1 million times in that example).

Name: Anonymous 2009-08-31 3:52

>>23
Just (coerce s 'list).

Name: Anonymous 2009-08-31 4:15

>>25
fff... I tried that before and it failed because I didn't read the lambda-list carefully enough, I was assuming (coerce output-type-spec obj) and not (coerce obj output-type-spec).

Name: Anonymous 2009-08-31 4:52

How peculiar, COERCE is actually slower for some reason:

CL-USER> (time-test 1000000 (coerce "ABC" 'list))
Evaluation took:
  0.375 seconds of real time
  0.375000 seconds of total run time (0.375000 user, 0.000000 system)
  [ Run times consist of 0.015 seconds GC time, and 0.360 seconds non-GC time. ]
  100.00% CPU
  904,049,172 processor cycles
  31,999,520 bytes consed

Name: Anonymous 2009-08-31 7:34

Lots of saging going on in this thread.

Name: Anonymous 2009-08-31 12:48

>>28
yeah but no need to join in like some dumb sheep that doesn't understand sage

Name: Anonymous 2009-08-31 14:27

>>29
pot, kettle, black, etc
here's a hint
GTFO

Name: Anonymous 2009-08-31 20:53

>>29
Please just go back to /b/. We were saging shit since 2001.

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