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

Challenge

Name: Anonymous 2013-08-02 23:48

Write a function in your language of choice that displays all its arguments on screen.
e.g. display("This function",1,0.9,'i','s',7/3,"displaying stuff") resulting in
"This function10.9is2displaying stuff"

Name: Challenge 2013-08-02 23:52

Write a function in your language of choice that makes >>1 go back to /g/.
e.g. https://boards.4chan.org/g/ resulting in
(>>1 goes back to /g/)

Name: Anonymous 2013-08-03 0:34

JavaScript
function display(){var s=[];for(i in arguments)s.push(arguments[i]);alert(s.join(" "))}

Name: Anonymous 2013-08-03 0:42


(define (disp . args) (for-each display args))

Name: Anonymous 2013-08-03 0:48

>>1
variable_name? X => X of text and X.size > 0 and if X.0 upcase? then Yes else X is '?'
function_name? X => X of text and not X~variable_name?

sym_head? C => C alpha? or ['_' '?' '<' '>'] has (X => X is C)
sym_body? C => C digit? or sym_head? C

//temporary hack; because Yes/No/Void should be functions
fn>asText O => if Yes is O then 'Yes'
               else if No is O then 'No'
               else if Void is O then 'Void'
               else '#invalid'

integer_digits2 Ds N => | Ds = list (N `%` 10) @Ds
                        | N = N `/` 10
                        | if N > 0 then integer_digits2 Ds N else Ds
integer>digits N => integer_digits2 [] N

integer>asText O =>
  | Sign = if O < 0 then '-' else ''
  | O = if O < 0 then O neg else O
  | DigitChars = O.digits: D => '0123456789'.D
  | [Sign @DigitChars] join_text

Keywords = list 'Yes' 'No' 'Void' 'and' 'or' 'if' 'then' 'else'
text>asText O =>
  if O is '' then '``'
  else if Keywords has:K => K is O then ['`' O '`'] join_text
  else | Q = if not O.0~sym_head? then '`'
             else if O has:X => not X~sym_body? then '`'
             else '' //no need for quotes
       | Xs = O: C => if C is Q then '\\`' //quote
                      else if C is '\n' then '\\n'
                      else C
       | [Q @Xs Q] join_text

// intersperse Xs with M
// infix 'and' [cat dog fox] --> [cat and dog and fox]
infix M Xs => if Xs end then []
              else | T = Xs tail
                   | if T end then Xs
                     else ((infix M T) headed M) headed Xs.head

list>asText O =>
  | S = O size
  | if S is 2 and O.0 is '\\'
    then _ break list>asText (['\\' O.1~asText] join_text)
    else Void
  | Max = 150
  | Xs = O take: if S < Max then S else Max
  | Xs = infix ' ': Xs: X => X~asText
  | E = if S < Max then [] else [' ...']
  | ['(' @Xs @E ')'] join_text

printable? X => if tag_of.X isnt fn then Yes
                else if [Yes No Void] has:S => S is X then Yes
                else exports_of.X has:E => E.0 is asText

asText X => if printable? X then X asText
            else [`#[` address_of.X.asText `]`] join_text

say @Xs => | Xs = infix ' ': Xs map: X => if tag_of.X is text then X else asText X
           | text_out [@Xs '\n'].join_text

Name: Anonymous 2013-08-03 0:58

this is not possible in a statically typed language

Name: Anonymous 2013-08-03 2:23

#include <iostream>
void display() {}
template<typename T, typename... U>
void display(T arg, U... rest) {
        std::cout << arg;
        display(rest...);
}
int main(void) {
        display("This function",1,0.9,'i','s',7/3,"displaying stuff");
}

Name: Anonymous 2013-08-03 2:25

>>7
neat!

Name: Anonymous 2013-08-03 2:27

Name: Anonymous 2013-08-03 2:52

sub display { print @_ }

Name: Anonymous 2013-08-03 3:22

>>9
it's using C++11

Name: 6 2013-08-03 3:24

this isn't possible in a statically typed language that doesn't have generics

Name: Anonymous 2013-08-03 8:02

The swearing will continue until code quality improves.

Name: Anonymous 2013-08-03 8:20

from functools import partial
display = partial(print, sep='')

Name: Anonymous 2013-08-03 9:28

>>14
Looks very elegant, what language is this?

Name: Anonymous 2013-08-03 9:30

>>15
'
>FIOC
>elegant

Name: Anonymous 2013-08-03 9:53

dicks

Name: Anonymous 2013-08-03 9:53

>>16
After a long day of ObjectiveJava++.NET, even brainfuck is elegant.

Name: Anonymous 2013-08-03 10:30

>>18
sucks for you, proletarian.

Name: Anonymous 2013-08-03 10:49

>>16
LLLLLLLLLLLLLLLLLLLLLLLLEEEEEEEEEEEEEEEEEEEEELLLLLLLLLLLLLLLLL
>LE /G/REENTEXT
>LE E/G/IN MEMES
>IMPLYIN/G/ LE 2013 ISGHTIYHTGYTG ISNT LE BEST REDDIT MEME XDDDDDDDDDDDDDDDDDDDDDD
LELELELELEELELELELELELELELEEEEEEEEEEEEEL

Name: Anonymous 2013-08-03 10:51

:)

Name: Anonymous 2013-08-03 11:07

>>16
That's right, Python is elegant.

Name: Anonymous 2013-09-01 17:04


Zermelo began to axiomatize set theory in 1905; in 1908, he published his results despite his failure to prove the consistency of his axiomatic system.

Name: Anonymous 2013-09-01 17:14

display = function(...) print(table.concat({...},"")) end
display("This function",1,0.9,'i','s',7/3,"displaying stuff")

Name: Anonymous 2013-09-01 19:21


Power set of a set A is the set whose members are all possible subsets of A. For example, the power set of {1, 2} is { {}, {1}, {2}, {1,2} } .

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