Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

Required fields*

Output some reserved words

For a computer language, a reserved word is a word that cannot be used as an identifier, such as the name of a variable, function, or label. For other computer languages, keywords can be considered as the set of the language instructions.

Challenge

Using your language of choice, write a code in the chosen language that given a number between one and ten, 1<=n<=10, outputs any n reserved words (keywords) of the chosen language.

Specifics

  • If the chosen language is case sensitive the outputted keywords must be also.
  • If the chosen language is not case sensitive the outputted keywords can be in any case.
  • If the chosen language has less than 10 keywords saying p, the code must output all the reserved words for any n between p and 10.
  • If possible specify in the answer whether you consider operators as keywords or not.

Possible samples for Java (JDK10)

  • n=1 --> true
  • n=3 --> try new interface
  • n=4 --> continue this long break

Possible samples for ><>

  • n=1 --> >
  • n=3 --> > < ^
  • n=4 --> > < \ /

Possible samples for Brain-Flak

  • n=1 --> (
  • n=3 --> ( ) [ ]
  • n=9 --> ( ) [ ] { } < >

Rules

  • The input and output can be given in any convenient format.
  • No need to handle invalid input values, valid inputs are: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10.
  • Either a full program or a function are acceptable. If a function, you can return the output rather than printing it.
  • If possible, please include a link to an on-line testing environment so other people can try out your code!
  • Standard loopholes are forbidden.
  • This is so all usual golfing rules apply, and the shortest code (in bytes) wins.

Answer*

Draft saved
Draft discarded
Cancel
4
  • \$\begingroup\$ I assume the fullwidth letters have consecutive character codes so you can just print the first n of those, which I can do in 8 bytes. \$\endgroup\$ Commented Jan 27, 2019 at 12:41
  • \$\begingroup\$ @Neil But are ten of those consecutive characters used as commands/operators? The A for example isn't used at all right now, is it? (Except in combination with KA or ⌕A.) \$\endgroup\$ Commented Jan 28, 2019 at 7:48
  • \$\begingroup\$ Actually A is a command and operator, but not a good one, as it can cause confusion between Find and FindAll, but you then get stuck again at H and O, which only get used as modifiers, and then Q isn't used at all, which limits you. Greek letters, then? \$\endgroup\$ Commented Jan 28, 2019 at 10:03
  • \$\begingroup\$ Never mind, those are variables, not commands, I guess. \$\endgroup\$ Commented Jan 28, 2019 at 10:55

AltStyle によって変換されたページ (->オリジナル) /