209

Stop upvoting trivial solutions It's easy to imagine why a new user would be frustrated when the highest-voted answer is a 3-byte solution in a golfing language with a built-in that nearly solves the problem. It feels like no matter how hard they golf in a conventional language, their solution will get much less recognition than an answer rushed out in the ...


136

Functions may output via their return value(s)


115

Functions may take input via function arguments


114

Consider the following pseudocode: if (x) { print "x is truthy"; } else { print "x is falsy"; } If it results in a runtime or a compile-time error then x is neither truthy nor falsy.


94

Programs may take input via GUI prompts (This is for languages, for which this is the closest alternative to STDIN, like JavaScript's prompt(), Mathematica's Input[] or InputString[], Matlab's input() and VBScript's InputBox().)


91

The default should be "programs or functions" This includes function-like constructs, including J's verbs and GolfScript's and CJam's blocks.


90

Programs may output by displaying it on screen. This makes it possible to use languages like Vim script that can't print output directly to stdout. Example from this challenge: $ echo "This is a test line!" | vim - -c 'nm Q vEUWvEuWQ|norm Q' Will display: THIS is A test LINE! ~ ~ ~ ~ ~ Within a Vim session. I think that this way of displaying the ...


83

Programs may output using their exit code... Exit codes are basically a return value for programs. If functions can output using their return values, it makes sense that programs should be able to do the same. Examples: Java exit codes C and C++ exit codes


80

Programs may take input via command-line arguments


78

Functions may take multiple arguments via currying For some functional programming languages like Haskell this is actually necessary, because only single-argument functions exist and functions with multiple arguments are (somewhat transparently) implemented as curried functions. (The alternative would be to take a list or tuple of the values, but that is ...


70

The contents of the tape post-execution may be used as a Turing machine's output


62

Functions may output via the same methods as full programs (This depends on how the poll goes, but could be any subset of STDOUT, STDERR and file.)


57

Functions may output by modifying their arguments or writing to out arguments Here, "out arguments" refers to arguments that are passed in by reference, so that modifying the value inside the function (as opposed to just overwriting the argument) also modifies the value outside the function (otherwise, the output value would not be observable after the ...


57

What SE could do for us... One of the most popular suggestions from "We're not a Q&A site, but what should be done about it?" is to add software support for answer metadata (mainly scores and languages). I believe this slightly different answer format would greatly reduce the impression that being the overall winner is important. Things this would make ...


52

I hate that people upvote Golfscript answers just because they are short. I can't help but imagine some very excited people with their mouth half open exclaiming "omg i cant believe thats a real program upvote lolz!!1!" These people will do so so for every piece of Golfscript code they see. Usually you find for instance Ruby/Python/Perl answers that are ...


51

Functions may take input via the same methods as full programs (This depends on how the poll goes, but could be any subset of STDIN, ARGV and file.)


51

Programs may combine two or more input methods For example, if the inputs are a string and an int, a function that takes a string as an argument and an int from STDIN would be valid. The input format must still be consistent for a given program.


50

For stack-based languages, function's input may be pushed to the stack before calling Stack-based languages may assume that the input for their function is automatically pushed to the stack.


50

No, invalid inputs may result in undefined behavior Requiring input validation only adds extraneous code to the answer and takes away from the challenge.


47

Restricting to just programs requires explicitly specifying "full program" rather than just "program" If the question requests a program, this can still be answered with a function. This allows for the fact that many people state "program" without thinking, not intending to exclude functions. For questions that wish to exclude functions, this should be ...


44

Input for Turing machines may be written to the tape pre-execution The read-write head should start on the leftmost cell of the portion of the tape containing the input.


42

Where applicable, Turing machines supporting multiple halt states may also output via their halt state This is essentially equivalent to programs outputting via their exit code.


39

How is it building a high quality library of questions and answers that will help experts? It isn't, not in the sense of asking Google and getting an answer. But I would argue that, as an exercise, code golf is highly instructive in areas such as lateral thinking, paradigm shifting, and developing a deep understanding of a programming language. While it ...


39

Truthy/Falsey should be taken as strictly defined in the given language. For example, in javascript, the following are always falsey: undefined null NaN 0 "" false And other values are always truthy.


38

SQLs may take input from a named table which is probably not good enough. But I don't know a better way.


Only top voted, non community-wiki answers of a minimum length are eligible