Here's my implementation:
buttSort = b . i . unwords . map concat $ map xmap fbf `xmap` fbs
where fbf = cycle [u, o] : cycle [cycle [o, u]]
fbs = map tacnoc . words $ "FIBONACCI BUTT SORT"
xmap = zipWith ($)
tacnoc = map (:[])
A bit of a kludge, to be honest. What I ought to have done is written a custom iterator function instead of juggling map and xmap, so it would be intrinsically aware of the space-skipping requirement and I wouldn't have to fuck with fbf.
FIBONACCIBUTTSORT
Name:
Anonymous2009-08-17 18:16
>>29
Like this?
buttSort = b . i . go (cycle [u, o])
where go fs (' ':xs) = " " ++ go fs xs
go (f:fs) (x:xs) = f [x] ++ go fs xs
go _ [] = []
A Dick Tower has a growth complexity of N, whereas a Binary Dicks Tree has an average growth complexity of only log(N).
Name:
Anonymous2009-08-17 20:23
Hello, /prog/, How are you this fine, fine evening? I'll just leave this here...
import java.io.IOException;
import java.util.*;
class Tag
{
private static Random generator = new Random(new Date().getTime());
private static Tag[] tags = new Tag[]
{
new Tag("b"), new Tag("i"), new Tag("u"), new Tag("o"),
};
private String name;
static Tag getRandomTag()
{
return tags[generator.nextInt(tags.length)];
}
private Tag(String name)
{
this.name = name;
}
public String getOpenForm()
{
return "[" + name + "]";
}
public String getClosedForm()
{
return "[/" + name + "]";
}
}
public class Progifier
{
public static void main(String[] args) throws IOException
{
Stack<Tag> tags = new Stack<Tag>();
Random generator = new Random(new Date().getTime());
while(System.in.available() > 0)
{
int b = System.in.read();
Guize I have written an implementation in C with UNICODE support. [m][b][i]#include<stdio.h> #include<wchar.h> #include<string.h> #include<locale.h> #include<errno.h>
Here's an example for UTF-8 input:
[spoiler]Invalid or incomplete multibyte or wide character: Invalid or incomplete multibyte or wide character[/spoiler]
Sometimes I wonder if The Sussman is actually tsundere for /prog/ and whenever I read a weird thread, I imagine him reading it and wincing and wondering what the fuck is this.
>>81
Without a shadow of a doubt yes. Don't worry it's entirely normal.
Name:
Anonymous2009-08-30 17:02
>>82
Unless of course, a second buttsort was being propagated in his proximity at 50Hz with an identical amplitude and 90 degree phase offset from the backround nose. Thus canceling out all active buttsorting.
>>94
Providing a mIRC implementation.
Usage: /bs testing buttsort
Can be used as an identifier, e.g. $buttsort(testing buttsort)
Caveat: Will not function well at all if the output ends up being > 900 characters. This means that you can only do roughly 90 characters worth of input text.
alias bs { say $buttsort($$1-) }
alias bbcode { return $+($chr(91), $1, $chr(93)) }
alias endbbcode { return $bbcode($+($chr(47), $1)) }
alias buttsort {
var %text = $$1-
var %output = $bbcode(b) $+ $bbcode(i)
var %i = 1
var %ctr = 1
var %t = $len(%text)
while (%i <= %t) {
var %g = $mid(%text, %i, 1)
var %spacequantity = 0
while (%i <= %t && %g == $chr(32)) {
inc %i
inc %spacequantity
var %g = $mid(%text, %i, 1)
}
if (%i > %t && %spacequantity > 0) { break }
if (%ctr == 1) {
var %output = %output $+ $str($chr(32), %spacequantity) $+ $bbcode(u) $+ %g $+ $endbbcode(u)
var %ctr = 0
}
else {
var %output = %output $+ $str($chr(32), %spacequantity) $+ $bbcode(o) $+ %g $+ $endbbcode(o)
var %ctr = 1
}
inc %i
}
var %output = %output $+ $endbbcode(i) $+ $endbbcode(b)
return %output
}
>>104
I attempted to reverse-engineer his ButtSort as it appeared kind of random, and it turned out it was just that, split letters, wrap each letter in a random tag, and wrap it with b/i tags.
Maybe I'll integrate various buttsorts into it and make it more customizable(add lots of keyword args which can specify all kinds of characteristics of your desired buttsort) another day.
public class buttSorter
{
public static void main(String args[])
{
StringTokenizer st = new StringTokenizer(" ");
String tempChar = "";
String input = "";
String output = "[b][i]";
String next;
int i = 1;
String tags[] = new String[]{"b", "i", "o", "u", "code", "sup", "sub"};
Random gen = new Random();
input = "" + JOptionPane.showInputDialog(
null,
"What do you wish to Buttsort?",
"Buttsorter",
JOptionPane.PLAIN_MESSAGE,
null,
null,
"");
try
{
st = new StringTokenizer(input);
}
catch(Exception e)
{
System.out.println("Tokenizer fucked up");
System.exit(1);
}
while(st.hasMoreTokens())
{
next = st.nextToken();
while(next != "")
{
i = Math.abs(gen.nextInt()) % 7;
if(next.length() > 1)
{
tempChar = next.substring(0, 1);
next = next.substring(1);
}
else
{
tempChar = next;
next = "";
}
I feel that I am not capable of programing buttsorts. Should I quit programming now or just try a lot harder?
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.
sortedbutt = '[b][i]'
tag = 'u'
for char in butt:
if char == ' ': # space does not use tag
sortedbutt += ' '
else:
sortedbutt += '[' + tag + ']' + char + '[/' + tag + ']'
tag = {'u': 'o',
'o': 'u'}[tag] # switch tag
The best way to increase cum load size is to be very hydrated, ... these essentially unhealthy foods will increase your fitness level and as ... www.lpsg.org › Main › Penis Enlargement - Cached - Similar
Cum Load Increase - Page 4 - 15 posts - Apr 19, 2006
Cum Load Increase - 15 posts - Jan 6, 2006
Any of you take supplements to increase your load? - 4 posts - Feb 21, 2005
if len(sys.argv) == 1:
filename = raw_input("File to buttsort: ")
elif len(sys.argv) == 2:
filename = sys.argv[1]
else:
exit("Wrong number of arguments.")
butt = file(filename).read()
sortedbutt = ''
tag = 'u'
for char in butt:
if char in ' \t\n\r': # space does not use tag
sortedbutt += char
else:
sortedbutt += '[' + tag + ']' + char + '[/' + tag + ']'
tag = {'u': 'o',
'o': 'u'}[tag] # switch tag
if len(sys.argv) == 1:
filename = raw_input("File to buttsort: ")
elif len(sys.argv) == 2:
filename = sys.argv[1]
else:
exit("Wrong number of arguments.")
butt = file(filename).read()
sortedbutt = '[b][i]'
tag = 'u'
for char in butt:
if char in ' \t\n\r': # space does not use tag
sortedbutt += char
else:
sortedbutt += '[' + tag + ']' + char + '[/' + tag + ']'
tag = {'u': 'o',
'o': 'u'}[tag] # switch tag
This is just one of those threads that never seems to die.
It brings back such good memories of a time less complicated.
The real world of college is quite painful.
(define s "Go back to /b/, please. Go back to /b/, please. Go back to /b/, please. ")
(string-append
(bb:foldl bb:sup s)
(bb:foldr bb:sup s)
(bb:foldr bb:sub s)
(bb:foldl bb:sub s)
((bb:default-buttsorter (bb:compose bb:u bb:sup)
(bb:compose bb:o bb:sub)) s))