Let us discuss the various implementations of theFIBONACCIBUTTSORT.
Name:
Anonymous2009-09-03 20:06
>>123
Dont feel too bad about it. Buttsorts requires advanced knowledge of parsing and string manipulation. They are a good exercise for an expert programmer, but for a beginner like yourself you shouldn't try and tackle them until you've learned enough about the aforementioned subjects.
>>124-chan here. Disregard that, I suck cocks! Buttsorting might be advanced material for Prague, but in the grand Scheme of things it's a fairly elementary exercise for anyone with a few weeks of experience. Also, ignore my next post, since I'll just be trolling you with it anyway. Have a nice anus !!
>>125
A Fibonacci Buttsort is an operation that can be performed on a string which outputs the string with alternating underline and overline tags. THISISAFIBONACCIBUTTSORT
-- buttsort.hs - an implementation of the Fibonacci Buttsort
import Data.Char (isSpace)
import Control.Monad.State
data Tag = Tag String
deriving (Show, Eq)
class Text a where
value :: a -> String
instance Text Char where
value = (:[])
instance (Text a) => Text [a] where
value = concatMap value
(<<) :: (Text a) => Tag -> a -> String
infixr <<
(Tag t) << x = "[" ++ t ++ "]" ++ value x ++ "[/" ++ t ++ "]"
[b, i, o, u, m] = map Tag ["b", "i", "o", "u", "m"]
buttsortW, buttsortC :: String -> String
buttsortW = (b <<) . (i <<) . unwords . zipWith (<<) (cycle [u, o]) . words
buttsortC = (b <<) . (i <<) . concat . flip evalState (cycle [u, o]) . mapM f
where f c = if isSpace c then return [c]
else do t <- get
modify tail
return $ head t << c
EXPERTHASKELLPROGRAMMING
Name:
Anonymous2009-09-07 17:24
>>139
That looks remarkably like the one I posted in the other thread — whereëver it went — in the control flow and use of cycle, anyway.
________ 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)
Well, buttsorting an anus is a bit like sorting an AVL tree.
Name:
Anonymous2009-11-24 5:43
HAXUS THE EMAIL
Name:
Anonymous2009-11-24 5:44
FUCK the Haxus meme just got haxed.
Name:
Anonymous2009-11-24 6:33
h
Name:
Anonymous2009-11-24 6:59
>>173
Don't you hate the kind of trolls that troll a board simply by putting technical terms together? also every idiot that'll jump in and say "but I know how to sort AVL trees!" AVL trees do NOT get sorted. They are self balanced you you!
>>177
How old are you 12? Its either that or you're clearly retarded either way. I'd rather be 5ft 6 than be as retarded as you.
Name:
Anonymous2009-11-24 10:13
>>177
Balancing involves sorting... they are just refering to being able to properly implement an AVL tree including the balancing (or sorting) aspects.
It's obvious to me, you must just have assburgers.
(defun cycle-fns (&rest functions)
(let* ((n (length functions))
(p 0)
(array (loop
with a = (make-array (list n)
:element-type 'function
:initial-element #'identity)
for function in functions
for i from 0 to (1- n)
do (setf (aref a i) function)
finally (return a))))
(lambda (&rest args)
(prog1
(apply (aref array p) args)
(setf p (mod (1+ p) n))))))
(defun bbcode (tag)
(lambda (i)
(format nil "[~A]~A[/~A]" tag i tag)))
>>195
Your cycle-fns function seems unnecessarily complicated, why not just use a circular list + pop or something like:
(let ((ht (make-hash-table :test #'equal)))
(defun cycle (&rest args)
(symbol-macrolet ((h (gethash args ht)))
(unless h (setf h args))
(pop h))))
>>197
stop using symbol-macrolet like a C preprocessor.
Name:
1972009-11-26 9:26
>>198
AFAIK, the way I'm using it is perfectly valid, and is one of the intended usages of the SYMBOL-MACROLET special operator. In that example, h represents the place of the arguments list in the hashtable, when used directly, you use the accessor to obtain the value, when used during SETF, you write to that place, so the symbol h represents a place within the hashtable. CL has things like WITH-SLOTS, which does the exact same thing - abstracts a place which points to a location within some object, and treats it like a symbol, which is perfectly fine usage. What is your argument against this?
>>208
You know I very nearly implemented a butt sort in befunge. Keeping track of state in befunge kinda blows, unless you're doing something like this:
>>210
I've occasionally thought about implementing a macro language for befunge, perhaps similar to brainfuck's Pebble. It could be useful since befunge offers very little in the way of abstraction.
I haven't really thought about this in any great detail, however, so I'm not sure how it would work. I'm not even sure what the exact goals would be. I'd be interested to see what thoughts other people have on this matter.
The main downside to this is, that I can foresee, is that it then becomes harder to write self-modifying code: you don't know where things are going to be or their precise layout.
>>211
I seem to recall some sort of support for modules or something similar in Funge-98. I could be mistaken, or it might have been considered and left unpsec'd or something. (I didn't see it in the spec just now, but I didn't look very hard either.)
>>212
There's the "fingerprint" extension mechanism, and some interpreters support mechanisms of writing fingerprints in befunge itself, but I'm not sure it really achieves what I want.