Write the longest sentence using keywords of a programming language

36

12

As the title said, the challenge is to write the longest sentence by only using the keywords of 1 programming language.

For instance, using the keywords of C++, it is possible to write this sentence:

do not try this float

What can you come up with?

Pubby

Posted 2013-01-09T03:20:35.197

Reputation: 1 239

Question was closed 2016-02-27T17:01:22.160

1Code challenges must be answerable with code. – Nathan Merrill – 2016-02-27T16:59:23.167

16

Shakespeare should be good for this http://en.wikipedia.org/wiki/Shakespeare_(programming_language)#List_of_reserved_words

– gnibbler – 2013-01-09T04:26:20.273

Are repetitions allowed? – elssar – 2013-01-09T07:07:24.253

3

@elssar Yes, so long as you don't abuse them along the lines of http://en.wikipedia.org/wiki/Buffalo_buffalo_Buffalo_buffalo_buffalo_buffalo_Buffalo_buffalo.

– Pubby – 2013-01-09T07:10:47.413

Is the score the total number of words, or just unique words? – Sir_Lagsalot – 2013-01-09T22:13:07.243

@Sir_Lagsalot Total number. – Pubby – 2013-01-09T23:27:34.403

I liked the answers! They are damn funny! – Pranit Bauva – 2013-01-12T08:26:09.943

1

You don't need many words to make arbitrarily long sentences. For example, with the C++ keywords you can do "Try this and try this and...". You can famously make an arbitrarily long sentence using only the word "buffalo", and as someone says on this page, you can do the same thing with "char" ("it's not too hard to see fishes of the genus Salvelinus scorching each other, given access to sufficiently powerful flamethrowers"). Maybe it would be more interesting if each word could only be used once?

– James – 2013-01-14T11:57:39.027

I'd like to see some corpus tested with keyword lists in various languages, and see what the longest strings of consecutive keywords are in literature. – Brigand – 2013-10-16T02:52:01.687

This is now my favorite question on this site. – Griwes – 2014-01-18T00:17:20.800

1

I was doing this before this question was posted. I was being quite immature at the time, so I'll warn you about explicit language. http://chat.stackoverflow.com/transcript/7?m=4671602#4671602

– Kendall Frey – 2014-01-18T06:42:46.403

6Finally a challenge that the APL guys can't win – kb_sou – 2014-01-20T22:45:54.103

Answers

34

Mathematica 100 80 unique words

Here's a start. All standard words in Mathematica begin with upper case. this includes I, the square root of negative 1.

On Sunday, And For All Times-- Assuming, On Opening Clear Dynamic Interactive Notebooks For Setting Contours, I Do Not Translate Missing Blue Arrays Which Span Temporary, Asynchronous, And Invisible Characters, Nor Do I Remove Undefined Arrowheads With Editable And Sound Outer Orange Roots Which Magnify Shallow Names Together With False Attributes (Because Most Axes Split Full Inner Kernels In Reverse Order)-- And While I Animate Undefined Quiet Ticks, I Begin With Tolerance And Operate On All Manual Matrices, Interleaving Circle With Cylinder, Boxed Skeleton With Compiled Cuboid, Red Cross With Nearest Timing Pattern, And Join Repeated Unique White Links With Heads ...


In case anyone is interested, here are 500+ words recognized by Mathematica (no additional libraries required). They are not all keywords, but experienced Mathematica programers will know and have used just about all of them.


{Abort, Above, Abs, Accumulate, Accuracy, AddTo, After, Alignment, All, Alternatives, Analytic, And, Animate, Animator, Annotation, Annuity, Antialiasing, Antisymmetric, Apart, Appearance, Append, Apply, Array, Arrays, Arrow, Arrowheads, Assert, Assuming, Assumptions, Asynchronous, Attributes, Automatic, Axes, Axis, Back, Background, Backslash, Backward, Band, Baseline, Because, Beep, Before, Begin, Below, Binarize, Binomial, Blank, Blend, Block, Blur, Bookmarks, Booleans, Bottom, Bounds, Boxed, Break, Button, Byte, Cancel, Cap, Cases, Cashflow, Catch, Ceiling, Cell, Cells, Censoring, Center, Character, Characters, Check, Checkbox, Chop, Circle, Clear, Clip, Clock, Close, Closed, Closing, Coarse, Coefficient, Collect, Colon, Colorize, Column, Commonest, Compile, Compiled, Complement, Complex, Compose, Composition, Compress, Condition, Cone, Congruent, Conjunction, Connect, Constant, Constants, Context, Contexts, Continue, Contours, Control, Convergents, Convolve, Copyable, Correlation, Cot, Count, Covariance, Cross, Cumulant, Cup, Curl, Cycles, Cylinder, Darker, Date, Debug, Decrement, Default, Defer, [Degree], Deinitialization, Deletable, Delimiter, Delimiters, Denominator, Deploy, Deployed, Depth, Derivative, Diagonal, Dialog, Diamond, Differences, Dilation, Dimensions, Direction, Directive, Disjunction, Disk, Dispatch, Display, Distribute, Distributed, Dithering, Divide, Dividers, Divisible, Divisors, Do, Dot, Down, Drop, Dynamic, Editable, Eigenvalues, Element, Eliminate, Empty, Enabled, Encode, End, Enter, Epilog, Equal, Equivalent, Evaluator, Except, Exists, Exit, Expand, Expectation, Exponent, Export, Expression, Extract, Factor, Factorial, Fail, False, File, Filling, Find, First, Fit, Flat, Flatten, Floor, Fold, Font, For, Forward, Frame, Front, Full, Function, Gather, General, Generic, Get, Graph, Graphics, Greater, Grid, Hash, Head, Heads, Histogram, Hold, Hue, Hyperlink, Hyphenation, I, Identity, If, Image, Implies, In, Increment, Inherited, Inner, Input, Insert, Inset, Install, Integer, Integers, Integral, Integrate, Interactive, Interleaving, Interval, Invisible, Item, Join, Joined, Kernels, Label, Labeled, Large, Larger, Last, Latitude, Launch, Left, Legended, Length, Less, Level, Lighting, Limit, Line, Links, List, Listable, Listen, Literal, Locked, Log, Longest, Longitude, Magnification, Magnify, Majority, Manipulate, Manual, Map, Masking, Material, Matrices, Maximize, Mean, Median, Medium, Menu, Mesh, Message, Messages, Method, Minimize, Minors, Missing, Modal, Mode, Modular, Module, Modulus, Moment, Monday, Monitor, Most, Mouseover, Multinomial, Multiplicity, Multiselection, Names, Nearest, Needs, Negative, Nest, Next, None, Nor, Norm, Normal, Normalize, Not, Notebook, Notebooks, Null, Number, Numerator, Off, Offset, On, Opacity, Open, Opening, Operate, Optional, Options, Or, Order, Ordering, Orderless, Orthogonalize, Out, Outer, Over, Overflow, Paclet, Pane, Panel, Paneled, Parallelize, Parameter, Parenthesize, Part, Partition, Paste, Path, Pattern, Pause, Permutations, Permute, Perpendicular, [Pi], Piecewise, Pivoting, Placed, Placeholder, Plain, Play, Plot, Plus, Point, Polygon, Polynomials, Position, Positive, Power, Precedence, Precedes, Precision, Prefix, Prepend, Previous, Print, Probability, Projection, Prolog, Properties, Property, Proportion, Protect, Protected, Pruning, Put, Pyramid, Quantile, Quantity, Quartics, Quartiles, Queueing, Quiet, Quit, Quotient, Radon, Random, Range, Raster, Rasterize, Rational, Rationals, Read, Real, Reap, Record, Rectangle, Reduce, Refine, Refresh, Reinstall, Release, Remove, Removed, Repeated, Replace, Resampling, Rescale, Residue, Resolve, Rest, Return, Reverse, Riffle, Right, Root, Roots, Rotate, Round, Row, Rule, Saturday, Save, Saveable, Scale, Scaled, Scan, Scrollbars, Select, Selection, Sequence, Series, Set, Setbacks, Setter, Setting, Shading, Shallow, Share, Sharpen, Short, Show, Sidebar, Sign, Signature, Simplify, Skeleton, Skip, Slot, Smaller, Socket, Solve, Sound, Sow, Spacer, Spacings, Span, Speak, Sphere, Splice, Split, Square, Stack, Star, Streams, String, Stub, Subfactorial, Subgraph, Subscripted, Subset, Subtract, Sum, Superset, Surd, Syntax, Table, Take, Tally, Temporary, Text, Texture, Therefore, Thread, Threshold, Through, Ticks, Times, Timing, Together, Toggle, Toggler, Tolerance, Tooltip, Top, Total, Trace, Tracers, Translate, Transpose, True, Tube, Tuples, Undefined, Underlined, Underscript, Unequal, Uninstall, Union, Unique, Unitize, Unset, Up, Variables, Vertical, Wedge, Weights, Which, While, Whitespace, With, Word, Write}

DavidC

Posted 2013-01-09T03:20:35.197

Reputation: 24 524

16Suddenly, I think Mathematica has too many keywords. – Mr. Llama – 2013-01-09T17:00:30.883

You may have a point. In Mathematica, everything is an expression and all symbols, such as the times-sign, are names when expressed in full, i.e.. long form, e.g. Times. I found 332 common English words in Mathematica. This does not include compound words such as AppendTo nor names of functions, of which there are literally thousands (but they are not really English words). – DavidC – 2013-01-09T17:54:33.873

332 was the count a few hours ago. I checked, and there are well over 500 English words acceptable for using in Mathematica programs. – DavidC – 2013-01-09T23:22:12.573

1@dude Many Option and Color names aren't in your list ... you could add up another 300, I guess :) – Dr. belisarius – 2013-01-12T14:52:54.297

1Aren't most of these identifiers, not keywords? – Geoff Reedy – 2013-01-14T17:38:30.727

@Geoff The breakdown of 57 words beginning with A or B is this. 26 Predicates, of which 24 take arguments: (Abort, Abs, Accumulate, Accuracy, AddTo, Animator, Animate, Annotation, Annuity, Apart, Append, Apply, Array, Arrow, Assert, Attributes, Band,Beep, Begin, Binarize, Binomial, Blend, Blur, Break,Button); 16 Settings and options: (Above, Alignment, Antialiasing, Antisymmetric, Arrowheads, Appearance, Asynchronous, Automatic, Axes, Axis, Background, Back, Backward, Baseline, Bookmarks, Boxed, Bottom); – DavidC – 2013-01-16T00:21:03.433

4 logical operators: (All, And, Alternatives, Assuming); 6 frontend tokens for formatting: (Analytic, Bounds, Above, Before,Below, After); 5 Identifiers, Delimiters, and Undefined Symbols: (Arrays, Because, Blank, Byte, Backslash, Block, Booleans). The word "Bra" was included due to a mistake on my part. – DavidC – 2013-01-16T00:21:23.293

46

C++, 25 unique words, 28 total

True friend, do goto register for this new short public class for private auto operator (while inline, return this signed template), else break & void this long volatile union.

Sir_Lagsalot

Posted 2013-01-09T03:20:35.197

Reputation: 4 898

2You can use and instead of &. :) – rightfold – 2014-01-18T00:15:48.543

@rightfold I considered it, but I felt counting alternate identifiers would make it too easy, and not all tools recognize them as keywords. – Sir_Lagsalot – 2014-01-22T18:38:43.837

19

While making sentences is not really my strong suite, here goes nothing -

Python 20 words

Finally, continue with import and raise global yield while class lambda is in break and try and print exec pass.

To help with checking, I wrote some code to check whether the words are in the keyword list or not.

from keyword import kwlist
from re import findall

def kwcheck(sentence):
    """Check whether all the words of a sentence are Python keywords"""
    words= findall(r'\w+', sentence)
    for word in words:
        if word.lower() not in kwlist:
            return False
    return True, len(words)

if __name__ == '__main__':
    sen= raw_input("Enter your sentence: ")
    print kwcheck(sen)

elssar

Posted 2013-01-09T03:20:35.197

Reputation: 579

14

The Importance of Education

-- by A. Coder Guy (written in Python)

Continue class, except if class is not for you.  
With no class, raise and assert!  Or yield, pass,
and break.  Try and continue!  Or - finally - return from class.

Brigand

Posted 2013-01-09T03:20:35.197

Reputation: 1 137

Is not for self maybe? It's not quite standard usage, but I think it'd be understandable. – Morgan Thrapp – 2016-06-21T20:01:50.703

4Since when is you a Python keyword? – kojiro – 2013-10-16T02:04:49.347

ha, good catch. Not sure how I can modify it; but feel free to downvote :-) – Brigand – 2013-10-16T02:46:39.950

11

Common Lisp

:In :Common :Lisp :a :keyword :is :simply :a :symbol :which :has :the :KEYWORD :home :package :which :is :true :of :all :symbols :starting :with :a :colon :so :you :can :construct :arbitrarily :long :sentences. :Do :I :win?

This, for example:

(every #'keywordp '(:In :Common :Lisp :a :keyword :is :simply :a :symbol :which :has :the :KEYWORD :home :package :which :is :true :of :all :symbols :starting :with :a :colon :so :you :can :construct :arbitrarily :long :sentences. :Do :I :win?))

Evaluates to T

See http://www.lispworks.com/documentation/HyperSpec/Body/26_glo_k.htm

Strigoides

Posted 2013-01-09T03:20:35.197

Reputation: 1 025

9

c#, 17 words

This looks like pretty reasonable technical mumbo-jumbo.
I guess it can be extended a bit.
foreach is a bit stretching the rules.
Used this keyword list.

Try explicit operator, in case implicit string foreach virtual struct is as unsafe as this volatile lock.

ugoren

Posted 2013-01-09T03:20:35.197

Reputation: 16 527

9

Factor - 109

"Take my-world and with happy? make items to-do. Pause. Self not happy?"

"Yes<<."

"From oldies?"

"Yes>>. Self sad."

"Haversin, listen, each and every formula become oldies. Become not sad, do-something greater-from-last. Or . My-arch self is_gold<<. Change-is_gold. Go-back where your_event_mask<< make happy? future. Fulfill promise of self. Remember-definition, light are-copies-of happy?"

"Sweetest-day near>> me?. Handle-me, handle-me. Sad self. Home not near>>. Home not near>> at all. Out-of-memory. Sad self, old<< self. Most near>> ones left self long ago."

"Haversin, change-known self. No sad, Haversin. Become happy? Forget what<< keep self from happy? My-arch self want>> self be> not sad. Before leave, remember-error."

"Not remember-error! Error not! My-array has-entry? not of error! Leave error!"

"Smart-if remember-error."

A lot of these are stretches, but it somewhat tells a story, so it makes up for that.

Matthew Rolph

Posted 2013-01-09T03:20:35.197

Reputation: 131

1 + for Factor!! – cat – 2016-04-26T00:14:31.413

Factor's especially good for this because it has no keywords :D – cat – 2016-06-24T20:19:50.673

8

Applescript, 30 words

I never thought I would post an Applescript answer on PPCG, but given Applescript's natural language design philosophy, it is perfectly suited for this question.

I'm not much of a wordsmith, so here's one just to get us started, but I fully expect others will easily beat this:

Beneath the eighth error, my third script is ignoring the sixth local copy
of the fourth transaction to the seventh property whose reference is given
to repeat every tenth second.

This is constructed just from Applescript's keywords, which are:

Keywords

about above after against and "apart from" around as "aside from" at back before beginning behind below beneath beside between but by considering contain contains continue copy div does eighth else end equal equals error every exit FALSE fifth first for fourth from front get given global if ignoring in "instead of" into is it its last local me middle mod my ninth not of on onto or "out" of over prop property put ref reference repeat return returning script second set seventh since sixth some tell tenth that the then third through thru timeout times to transaction TRUE try until use where while whose with without

The following may or may not be considered valid for this challenge:

Built-in classes and properties

alias application boolean centimetres centimeters character class contents constant "cubic centimetres" "cubic centimeters" "cubic feet" "cubic inches" "cubic metres" "cubic meters" "cubic yards" date "date string" day "degrees Celsius" "degrees Fahrenheit" "degrees Kelvin" feet file frontmost gallons grams id inches integer item kilograms kilometres kilometers length list litres liters metres meters miles month name number ounces paragraph "POSIX file" "POSIX path" pounds quarts "quoted form" real record reference rest reverse "RGB color" running script "square feet" "square kilometres" "square kilometers" "square metres" "square meters" "square miles" "square yards" text time "time string" "unit types" version weekday word yards year

Built-in Commands

activate "ASCII character" "ASCII number" beep "choose application" "choose color" "choose file" "choose file name" "choose folder" "choose from list" "choose remote application" "choose URL" "clipboard info" "close access" copy count "current date" delay "display alert" "display dialog" "display notification" "do shell script" get "get eof" "get volume settings" "info for" launch "list disks" "list folder" "load script" "localized string" log "mount volume" offset "open for access" "open location" "path to" "path to resource" "random number" read round run "run script" say "scripting components" set "set eof" "set the clipboard to" "set volume" "store script" summarize "system attribute" "system info" "the clipboard" "time to GMT" write

Considering/Ignoring attributes

case diacriticals hyphens "numeric strings" punctuation "white space"

Digital Trauma

Posted 2013-01-09T03:20:35.197

Reputation: 64 644

8

Shakespeare

44 words, 28 unique

Yes, all of these words really have keyword-level significance in Shakespeare. Shakespeare character names, normal nouns and adjectives are also a core part of the language, but I thought they'd bloat the list too much for this exercise.

You must listen to your heart to enter your mind: the heart shall recall the difference between the exit and the return, to let you remember you are your art, and so you are the product of yourself and an act better than yourself.

Luke

Posted 2013-01-09T03:20:35.197

Reputation: 5 091

7

Ruby, 41 words

True self, do not begin class break, end class break, ensure class break, redo and redo class break, retry class break, rescue class break, or yield class break, until next class end (or next class module or next class return), or else!

That's just using words listed as actual keywords. There are a lot of other words that act like keywords because they're methods of the kernel or instance methods of Class.

A cheesier approach would start

Do not def "alias","begin","break",...

histocrat

Posted 2013-01-09T03:20:35.197

Reputation: 20 600

3

C++.

A lot of repeated words, but a borderline sensible sentence:

If this volatile friend false and do return unsigned public union template throw union
template goto void for false friend not using class, and try switch for new protected
union using true friend, or else catch long, private break using this public operator
switch for explicit union using new virtual friend if union for this friend not long and
true.

Aka: If this moody girl won't sign the marriage license, throw away the license and find a nice new girl--and if that doesn't work out, just try a...virtual union over the "public operator switch".

Oh, as far as exact number of words goes, sorry but I'm too lazy to count.

Jerry Coffin

Posted 2013-01-09T03:20:35.197

Reputation: 539

3

Python, 48 words

class, try (if lambda is in class) and continue as if in break from global import and raise yield for return from exec; else, while lambda is not in class, continue with print import except for def, finally pass 'assert elif' or else del is not for class.

This contains every keyword in keyword.kwlist

I think some explanation is required here: This sentence is said to a school class that is currently in some place called exec. In the class, there are amongst others two people named lambda and def. def should pass the assert elif test because otherwise the DEL (German ice hockey league) is nothing for the class.

jazzpi

Posted 2013-01-09T03:20:35.197

Reputation: 846

<speechless> o.o – cat – 2016-04-26T00:12:16.043

2

ECMA

A bit of broken English due to the fact that ECMA reserved words contain neither conjunctions nor more than one conjugation of verb. It's really an imperative language!

Do try this new typeof case, with this default catch function.

In this case, break in with this switch. If catch break, return with this new switch; finally throw in with this new function.

kojiro

Posted 2013-01-09T03:20:35.197

Reputation: 717

2

Perl - several entries

when given tied package untie, unpack and unlink until open, redo each package (link, pack and bind or tie) or dump if not open; next, read map, write state, reverse and return system. (28 distinct words)

bless (not hex) my rand-y flock; continue until values accept no sin; study END times, accept sleep and die; CHECK keys and close each crypt lock. (25 distinct words)

tell our next caller: "use fork and pipe; push, break, delete, kill, and DESTROY." (13 distinct words)

Ralph Marshall

Posted 2013-01-09T03:20:35.197

Reputation: 729

1

Haskell (~29-ish)

In case of foreign type, import data module; where as for all (forall) in qualified class, if hiding, then do default (let in, deriving instance of data family where qualified, otherwise data instance of type family); else type in fix (infix).

In Haskell, data family is a separate keyword from data, likewise with type family, and deriving instance is separate from deriving and instance. I am using forall as two words (counting only one), where as as one (counting two), and infix as two (counting one).

archaephyrryx

Posted 2013-01-09T03:20:35.197

Reputation: 1 035