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

Return to Answer

Mod Removes Wiki by Doorknob
added 74 characters in body
Source Link
Gareth
  • 11.4k
  • 1
  • 37
  • 86

Input

1!:1[1 will take one line of input terminated by pressing the enter key.

1!:1[3 will take a number of lines of input (terminated by Ctrl-D on my Mac, Ctrl-C on Windows).

If you're trying to input numbers, using ". will evaluate the string and return a list of numbers ready to be manipulated. If you're taking in one number but need to operate on the digits individually, ".,' ',. (thanks to Jan Dvorak's comment for this) or "."0 will put spaces in betweensplit the string into separate digits before evaluating them:

 ".,'"0[1!:1[1
12345
1 '2 3 4 5
 ".,.1!:1[1
12345
1 2 3 4 5

If you're reading in strings, the shortest way to get a boxed list of separate strings is to use ;:. This works best for space separated strings:

 ;:1!:1[1
hello world
┌─────┬─────┐
│hello│world│
└─────┴─────┘

Input

1!:1[1 will take one line of input terminated by pressing the enter key.

1!:1[3 will take a number of lines of input (terminated by Ctrl-D on my Mac, Ctrl-C on Windows).

If you're trying to input numbers, using ". will evaluate the string and return a list of numbers ready to be manipulated. If you're taking in one number but need to operate on the digits individually, ".,' ',. will put spaces in between the digits before evaluating them:

 ".,' ',.1!:1[1
12345
1 2 3 4 5

If you're reading in strings, the shortest way to get a boxed list of separate strings is to use ;:. This works best for space separated strings:

 ;:1!:1[1
hello world
┌─────┬─────┐
│hello│world│
└─────┴─────┘

Input

1!:1[1 will take one line of input terminated by pressing the enter key.

1!:1[3 will take a number of lines of input (terminated by Ctrl-D on my Mac, Ctrl-C on Windows).

If you're trying to input numbers, using ". will evaluate the string and return a list of numbers ready to be manipulated. If you're taking in one number but need to operate on the digits individually, ".,. (thanks to Jan Dvorak's comment for this) or "."0 will split the string into separate digits:

 "."0[1!:1[1
12345
1 2 3 4 5
 ".,.1!:1[1
12345
1 2 3 4 5

If you're reading in strings, the shortest way to get a boxed list of separate strings is to use ;:. This works best for space separated strings:

 ;:1!:1[1
hello world
┌─────┬─────┐
│hello│world│
└─────┴─────┘
deleted 13 characters in body
Source Link
Gareth
  • 11.4k
  • 1
  • 37
  • 86

Input

1!:1[1 will take one line of input terminated by pressing the enter key.

1!:1[3 will take a number of lines of input (terminated by Ctrl-D on my Mac, I think it's Ctrl-ZC on Windows).

If you're trying to input numbers, using ". will evaluate the string and return a list of numbers ready to be manipulated. If you're taking in one number but need to operate on the digits individually, ".,' ',. will put spaces in between the digits before evaluating them:

 ".,' ',.1!:1[1
12345
1 2 3 4 5

If you're reading in strings, the shortest way to get a boxed list of separate strings is to use ;:. This works best for space separated strings:

 ;:1!:1[1
hello world
┌─────┬─────┐
│hello│world│
└─────┴─────┘

Input

1!:1[1 will take one line of input terminated by pressing the enter key.

1!:1[3 will take a number of lines of input (terminated by Ctrl-D on my Mac, I think it's Ctrl-Z on Windows).

If you're trying to input numbers, using ". will evaluate the string and return a list of numbers ready to be manipulated. If you're taking in one number but need to operate on the digits individually, ".,' ',. will put spaces in between the digits before evaluating them:

 ".,' ',.1!:1[1
12345
1 2 3 4 5

If you're reading in strings, the shortest way to get a boxed list of separate strings is to use ;:. This works best for space separated strings:

 ;:1!:1[1
hello world
┌─────┬─────┐
│hello│world│
└─────┴─────┘

Input

1!:1[1 will take one line of input terminated by pressing the enter key.

1!:1[3 will take a number of lines of input (terminated by Ctrl-D on my Mac, Ctrl-C on Windows).

If you're trying to input numbers, using ". will evaluate the string and return a list of numbers ready to be manipulated. If you're taking in one number but need to operate on the digits individually, ".,' ',. will put spaces in between the digits before evaluating them:

 ".,' ',.1!:1[1
12345
1 2 3 4 5

If you're reading in strings, the shortest way to get a boxed list of separate strings is to use ;:. This works best for space separated strings:

 ;:1!:1[1
hello world
┌─────┬─────┐
│hello│world│
└─────┴─────┘
Source Link
Gareth
  • 11.4k
  • 1
  • 37
  • 86

Input

1!:1[1 will take one line of input terminated by pressing the enter key.

1!:1[3 will take a number of lines of input (terminated by Ctrl-D on my Mac, I think it's Ctrl-Z on Windows).

If you're trying to input numbers, using ". will evaluate the string and return a list of numbers ready to be manipulated. If you're taking in one number but need to operate on the digits individually, ".,' ',. will put spaces in between the digits before evaluating them:

 ".,' ',.1!:1[1
12345
1 2 3 4 5

If you're reading in strings, the shortest way to get a boxed list of separate strings is to use ;:. This works best for space separated strings:

 ;:1!:1[1
hello world
┌─────┬─────┐
│hello│world│
└─────┴─────┘

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