Write an aphorism using valid code

39

10

Can you write an aphorism in at most 4 lines of code ?

Code should read as much as possible as an aphorism in plain English and should return the boolean true.

Language: of choice.

Criteria for accepted answer: Most votes in 180 30 days. (8th of July 2014)

Originality: can be an old aphorism but a creative one would be much more appreciated.

Eduard Florinescu

Posted 2014-01-09T17:39:21.443

Reputation: 1 863

Question was closed 2016-04-22T22:03:50.750

1What is the max line length ? – kyle k – 2014-01-09T23:54:19.523

@kyle k, 90 characters should should suffice, mostly for estetic, readability reasons, also good aphorisms tend to be short :) – Eduard Florinescu – 2014-01-09T23:57:27.997

1Ruby - !!"[ insert whatever aphorism you want here ]" – Doorknob – 2014-01-10T02:54:09.813

1@DoorknobofSnow That would be a valid answer but I doubt that would get much of the votes. – Eduard Florinescu – 2014-01-10T08:50:15.257

1Not sure that Shakespeare quotes qualify as aphorisms. – Blazemonger – 2014-01-24T18:11:55.613

@Blazemonger I think that quote qualifies as an aphorism – Eduard Florinescu – 2014-01-27T19:06:13.727

Answers

51

Python

import this
love = this
this is love, love is not True or False, love is love
# (True, True, True)

Okay, this returns a tuple of Truths, but that itself evaluates as True anyway.

Manuel Ebert

Posted 2014-01-09T17:39:21.443

Reputation: 625

29

Forth

2 : b or ! 2 ." b" ;
: that s" the questi" on ;

Darren Stone

Posted 2014-01-09T17:39:21.443

Reputation: 5 072

20

C:

You'll have to squint a bit to read this one :-)

int x(){ int __,L        ;
     return (__ |__ ||__ |__ ,__,__ ,__ ,__ ,__  ,
             __||  1||__ |  1L/L|__||__|1/__|  1L)
                                ;   }

You might notice a potential division-by-zero error on line 3, but this is never executed because the expression evaluates as true before the calculation is performed.

r3mainer

Posted 2014-01-09T17:39:21.443

Reputation: 19 135

Forest gump! +1 – Eduard Florinescu – 2014-01-09T23:44:26.843

8Could you please translate, for those of us without the necessary squinting skills? – Bob – 2014-01-25T14:32:24.883

@Bob Do you want a breakdown of the C code, or a clearer rendering of the ASCII art? – r3mainer – 2014-01-26T20:41:36.537

Oh, the C code is easy enough (__ is an identifier, couple bitwise and logical ORs and comma operators, which are all insignificant because it's all logical ORed with a 1 evaluating to true). It's the ASCII art that's a little difficult to read. – Bob – 2014-01-27T04:32:58.487

3

@Bob OK, here's something similar. (Not valid C code, but easier to read, I hope.)

– r3mainer – 2014-01-27T09:23:38.203

Thanks! It's obvious in retrospect :\ (I was trying to read it one line at a time) – Bob – 2014-01-27T09:49:51.450

19

It's difficult to avoid string literals, comments and tricks fo this kind, but I tried to keep them to a mininum. Also, the first line makes no sense. Well, I had fun doing it

F#

(fun () -> (fun (_) -> // fun fun? wtf
try not <| failwith("me") ; (*but*) with |Failure((*co*)me(*s*)) -> true)("learning"))()
// "Try not to fail with me, but with failure comes true learning

I could also do some declaration abusing, but I ended up not finding a way to return true:

let the,bodies,hit_the=floor(0.0),(),()

or

let the_games=bigint() //pun intended

I really need to stop with the puns.

Conrad Clark

Posted 2014-01-09T17:39:21.443

Reputation: 299

18

C

No string literals or comments:

Better(to,re);main(silent){and();}be(thought,a,fool){}
than(to,open,your,mouth);and(){}remove(all,doubt);

Split over two lines, but one would work fine as well.

When compiled using gcc on Linux (x86-64), this produces an executable which exits with success (exit code 0), the same as the true Unix utility; this being how I choose to interpret the requirement of returning boolean true in a non-scripting language.

Note: notwithstanding the abuse of the "implicit int" rule, the principal trick behind this program is that while a C program that falls off the end of main without a return statement will usually result in a non zero exit code, by calling another function we can set the EAX register which is then used as the exit code of the program. This is of course totally undefined behaviour and utterly non portable.

ecatmur

Posted 2014-01-09T17:39:21.443

Reputation: 1 675

17

Python

war=peace=freedom=slavery=ignorance=strength=0
war is peace|freedom is slavery|ignorance is strength

Power=a=means=it=an=end=0
Power is not (a, means, it is (an, end))

JavaScript

You=true;function BigBrother(){};BigBrother.isWatching=function(y){return y};
BigBrother.isWatching(You)

grim

Posted 2014-01-09T17:39:21.443

Reputation: 397

15

C#:

short life = 0;
return (life is short);

"Life is short" (Hippocrates)

thepirat000

Posted 2014-01-09T17:39:21.443

Reputation: 588

3Too bad there is no literal specifiers for shorts! It would be neat to do var life = 0s; – Ben Reich – 2014-01-24T16:44:28.767

14

Ruby

class String
  def before(b) self < b end
end

A bit lengthy, but gets us a few aphorisms:

"age".before("beauty")
"business".before("pleasure")
"pearls".before("swine")

And (stretching slightly):

dont = []; y = 1
dont.count + y or ('chickens'.before('they hatch'))

bclune

Posted 2014-01-09T17:39:21.443

Reputation: 141

1+1: for y or. – wchargin – 2014-01-26T17:37:56.633

11

Scala

Some apply Double forall _; None isEmpty

lmm

Posted 2014-01-09T17:39:21.443

Reputation: 231

11

CoffeeScript

2 * @wrong isnt @right

=> true

Jon Jensen

Posted 2014-01-09T17:39:21.443

Reputation: 211

10

C++

bool life = true;
bool fair = false;

assert(life != fair);

Jun

Posted 2014-01-09T17:39:21.443

Reputation: 101

8

Python

love=[True];all,fair,war=love*3
all is fair in love and war

Claus

Posted 2014-01-09T17:39:21.443

Reputation: 81

7

An aphorism about http verbs, in

Ruby

puts do
something idempotent but are considered to be unsafe
because if the value at the beginning of a chain of calls is one possibly the value at the
end != 1

histocrat

Posted 2014-01-09T17:39:21.443

Reputation: 20 600

4

C

if ((ifs && ands) == (pots && pans))
    work_for_tinkers_hands = FALSE;

Paul R

Posted 2014-01-09T17:39:21.443

Reputation: 2 893

4

Javascript

function be(who) {
   if (who == 'thine own self') {
      return true;
   }
}

An approximation of "To thine own self be true."

I'm kind of fudging with the requirements, since it only returns true in one particular case ... but I'm hoping you'll let it slide because the return value is actually part of the aphorism.

jawns317

Posted 2014-01-09T17:39:21.443

Reputation: 1 132

4

I got a wonderful error while attempting this:

It's very much inspired by Darren Stone's answer.

TypeError: Cannot use 'in' operator to search for 'tis nobler' in mind to suffer the The Slings and Arrows of outrageous fortune

Javascript

[2].be || ! [2].be ; this.is, "the question"

It returns an implicit true.

Slightly less terse, with a question mark:

[2].be || ! [2].be? is = this: !"the question"

Zemnmez

Posted 2014-01-09T17:39:21.443

Reputation: 59

4

C

main(int I,char **think) {char *a="there"; for (;--I;) a['m'];}

jmc

Posted 2014-01-09T17:39:21.443

Reputation: 41

1You can remove the types in declarations. Also something has to be done to a's declaration... It gets in the way when you read – mniip – 2014-01-24T19:58:56.927

I left them because my compiler gave me errors without them, so I wanted to be very adherent :P – jmc – 2014-01-25T07:54:05.753

4

C

int main(int fear, int* computers){ int

    i; do { !fear; computers[i]; fear; "the lack of them";

} while();return true;}

I do not fear computers, I fear the lack of them.

-Isaac Asimov

Magikhead

Posted 2014-01-09T17:39:21.443

Reputation: 41

3

A bit lazy, but my take.

Python:

life = short = True; art = long = True; life=art
life is short and art is long

JavaScript:

The = word = 'Yoga'
has = been = 'vulgarized'
and = does = not=  mean = anything =Date.now() ,!''
//Swami Rama 

Eduard Florinescu

Posted 2014-01-09T17:39:21.443

Reputation: 1 863

3

PHP

$all = array('not well', 'not well', 'not well', 'well'); 
$end = array_pop($all);
$all = ($end == 'well') ? $end : 'not well';
return true;

"All's well that ends well."

jawns317

Posted 2014-01-09T17:39:21.443

Reputation: 1 132

3

Q

any bird:`int$"hehand"=2^`int$"hebush"

and

(./) 2_iscomp:any 3,'s:"a",'"crowd"

nightTrevors

Posted 2014-01-09T17:39:21.443

Reputation: 171

3

PHP

An apple a day...

$aphorism = function(){
    for($day=1;$day<=365;$day++) $apple++;
    return ($apple==365) ? true : 'doctor';
};

vault111

Posted 2014-01-09T17:39:21.443

Reputation: 41

3

Common Lisp

(Do ((as)) ('(I say no)t) as I do)
(time (and 'tide (wait-for 'no-man))) ;requires sbcl

Jason

Posted 2014-01-09T17:39:21.443

Reputation: 201

3

Lua

-- all search is in vain
function search() end
-- only the void is true
function void() return function() return true end, true end
-- and what remains is to
for ever in void() do repeat search("light") until true end
return true

xaberus

Posted 2014-01-09T17:39:21.443

Reputation: 31

3

JavaScript

return (Do || !Do) || (there == !try);

return 2 * be || !(2 * be);

Blue Sheep

Posted 2014-01-09T17:39:21.443

Reputation: 221

1Upvote for the Yoda one, but I am thinking there should be a ban on "To be or not to be". – Jonathan Van Matre – 2014-02-21T17:53:13.513

3

R

the_whole <- c(-1,-1)
the_part <- -1
the_whole > sum(the_part,the_part)

-Socrates

dfernig

Posted 2014-01-09T17:39:21.443

Reputation: 191

2

Simply-Basic 84

Label 1;a random number between 0 and 1~should be stored in~A
If A is equal to 1 Then Display A End;Stop&Else,Go to label 1
:End; Otherwise destroy quantum transmitters internationally.
Since quantum transmitters are gone, power lost. KA-POW, yes?

Timtech

Posted 2014-01-09T17:39:21.443

Reputation: 12 038

2

Prolog

waste(not).

want(X) :-
    waste(X).

sep332

Posted 2014-01-09T17:39:21.443

Reputation: 121

2

Python

be = that = the = question = 1
2 - be or not 2 - be
that is the & question

YAtOff

Posted 2014-01-09T17:39:21.443

Reputation: 121

2

Ruby

Not the most elegant solution, but very easy to read

def you_know_meaning(x) true end

!!!("aphorism" != "aphorism" unless you_know_meaning "aphorism")

=> true

Zbynek

Posted 2014-01-09T17:39:21.443

Reputation: 131

2

JAVA

public static boolean think(){return true;}public static boolean so()
{return true;}public static boolean be(){return true;}static{boolean i=true;
    System.out.println((i==think())?so():i==be());
}

I think so i be --Descartes

masterX244

Posted 2014-01-09T17:39:21.443

Reputation: 3 942

2

C++

int main() {
  int right,might;
  might==right;
}

Might is right.

user10766

Posted 2014-01-09T17:39:21.443

Reputation:

2

Haskell

Be original!

do otherwise

It returns True.

lortabac

Posted 2014-01-09T17:39:21.443

Reputation: 761

1

Rebol

Rebol []
between: :if thought: expression: true lies: func ['a 'b] [a != b]

between thought and expression [lies a lifetime]


Some explanation

The above code translates to:

if thought and expression [lies word-arg1 word-arg2]

The if statement is true so the lies function is called which returns true as along as the two arguments provided are different.

draegtun

Posted 2014-01-09T17:39:21.443

Reputation: 1 592

1

Perl

sub between (&@) { $_[1] if $_[0]->() } sub lies { $_[0] ne $_[1] }
my ($thought, $expression) = (1,1);

between {$thought and $expression} lies a => 'lifetime';

NB. Above works fine with (or without) strict and warnings pragmas.

draegtun

Posted 2014-01-09T17:39:21.443

Reputation: 1 592

1

Ruby vs Friedrich Nietzsche

=> class Lie
=>   def self.is_a_condition_of?(life);true;end
=> end
=> Lie.is_a_condition_of?("life") # => true

user13426

Posted 2014-01-09T17:39:21.443

Reputation:

1You're admitting also that self is a condition of life :) +1 – Eduard Florinescu – 2014-01-27T12:19:30.087

1

Javascript

get: with(this) 1;

I think this makes sense.

Edit: was notified it didn't return true, well now it does.

Zemnmez

Posted 2014-01-09T17:39:21.443

Reputation: 59

Doesn't return true – Eduard Florinescu – 2014-02-04T20:41:32.490

1

Is my use of the literal string true cheating?

This is an AutoHotkey script:

Be("true") to yourself

Be(msg) {
    MsgBox % msg
}

Person93

Posted 2014-01-09T17:39:21.443

Reputation: 171

1

Rebol

love: true 
war:  false

if true? any [love is blind and war is hell] [make love not war]

draegtun

Posted 2014-01-09T17:39:21.443

Reputation: 1 592

1

Not one of my favourite songs, still a great album.

PHP

$_GET['this'] or die(!0);

Reads as: Get this or die! (No!)

Get This
Slipknot
1999

Vereos

Posted 2014-01-09T17:39:21.443

Reputation: 4 079

1

T-SQL

I made several attempts at this challenge before arriving at an answer that expresses truth through the code itself. After a few attempts at turning favorite quotes into pithy code translations, I realized the way to go was to set aside quotation entirely and let the language of choice simply speak the wisdom it is capable of speaking.

Since SQL is verbose, I have chosen to break this 4-line program into more lines for ease of reading without horizontal scrolling. The properly "golfed" version may be found on this SQLFiddle.

DECLARE @mindInTurmoil BIT = 'True'
Samsara: SELECT 'equanimity' AS Attitude, 0 AS Ego INTO #Self
    WHERE @mindInTurmoil = 'True' 
IF (SELECT TOP 1 Attitude FROM #Self ORDER BY Ego) = 'equanimity' 
    SET @mindInTurmoil = 'False' ELSE GOTO Samsara
SELECT CASE @mindInTurmoil 
    WHEN 'True' THEN 'False' WHEN 'False' THEN 'True' END AS Liberation

Returns:

Liberation
----------
True

Jonathan Van Matre

Posted 2014-01-09T17:39:21.443

Reputation: 2 307

1

Java (probably others too)

boolean hasExceptions(Rule rule) { return rule != this; }

"There are always exceptions, except to this rule." - by me.

Mark Jeronimus

Posted 2014-01-09T17:39:21.443

Reputation: 6 451

1

JavaScript

function healthy_community(diversity){
    return (diversity === true) ? true : false;
}
healthy_community(true);

Richard Andrew Lee

Posted 2014-01-09T17:39:21.443

Reputation: 111

why not just return diversity ? – Eduard Florinescu – 2014-02-26T22:27:15.620

well if you pass 'kinda sorta' it will return false. it must be absolutely true in type and value. – Richard Andrew Lee – 2014-03-03T16:41:05.607

1

Groovy

short Short;
short life = Short;
assert life.is(Short);

md_rasler

Posted 2014-01-09T17:39:21.443

Reputation: 201

1

Java

for (Person person : people) {
    if (!HouseTypeEnum.GLASS_HOUSE.equals(person.getResidence().getHouseType()))
        throw new StonesException();
}

user21375

Posted 2014-01-09T17:39:21.443

Reputation: 111

1Two problems: This doesn't compile because we don't have a Person class or a HouseTypeEnum or a StonesException or (etc). Also "should return the boolean true." This code doesn't return any value. – Justin – 2014-05-16T21:13:24.973

1

Mathematica

 mo[thing__] := MemberQ[{thing}, money | problems | True]
 mo[money~mo~problems]

chuy

Posted 2014-01-09T17:39:21.443

Reputation: 389

1

Javascript

with = javascript = we = can = create = any = aphorism = returning = true;

Fabricio

Posted 2014-01-09T17:39:21.443

Reputation: 1 605

Yes, but is it creative? ;) – Doorknob – 2014-05-16T23:47:41.980

1

C

This quote is a line from My Fair Lady. See here https://www.youtube.com/watch?v=uVmU3iANbgk

#include <stdio.h>
/*the rain */int /*Spain falls*/ main/*ly*/(){return puts("on the plane")>0?1:0;}

bacchusbeale

Posted 2014-01-09T17:39:21.443

Reputation: 1 235

0

TI-BASIC 

2_be or not(2_be)

Timtech

Posted 2014-01-09T17:39:21.443

Reputation: 12 038