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

Commonmark migration
Source Link

#Read from STDIN

Read from STDIN

GolfScript can read from stdin:

"#{STDIN.read}"

This will continue reading from STDIN until the EOF is reached. Alternatively:

"#{STDIN.gets}"

or

"#{STDIN.readline}"

Other things available:

getbyte
getc
gets([sep])
gets(limit)
gets(sep, limit)
inspect # perhaps useful for an underhanded contest
isatty
read([length])
readbyte
readchar
readline([sep])
readline(limit)
readline(sep, limit)
readlines([sep])
readlines(limit)
readlines(sep, limit)
readpartial(maxlen [, outbuf])

For each of these, they can only be used once (and also once for each change of the parameter, also once more with empty parentheses); after that, the original value is what you'll get instead of a new value.

#Read from STDIN

GolfScript can read from stdin:

"#{STDIN.read}"

This will continue reading from STDIN until the EOF is reached. Alternatively:

"#{STDIN.gets}"

or

"#{STDIN.readline}"

Other things available:

getbyte
getc
gets([sep])
gets(limit)
gets(sep, limit)
inspect # perhaps useful for an underhanded contest
isatty
read([length])
readbyte
readchar
readline([sep])
readline(limit)
readline(sep, limit)
readlines([sep])
readlines(limit)
readlines(sep, limit)
readpartial(maxlen [, outbuf])

For each of these, they can only be used once (and also once for each change of the parameter, also once more with empty parentheses); after that, the original value is what you'll get instead of a new value.

Read from STDIN

GolfScript can read from stdin:

"#{STDIN.read}"

This will continue reading from STDIN until the EOF is reached. Alternatively:

"#{STDIN.gets}"

or

"#{STDIN.readline}"

Other things available:

getbyte
getc
gets([sep])
gets(limit)
gets(sep, limit)
inspect # perhaps useful for an underhanded contest
isatty
read([length])
readbyte
readchar
readline([sep])
readline(limit)
readline(sep, limit)
readlines([sep])
readlines(limit)
readlines(sep, limit)
readpartial(maxlen [, outbuf])

For each of these, they can only be used once (and also once for each change of the parameter, also once more with empty parentheses); after that, the original value is what you'll get instead of a new value.

Mod Removes Wiki by Doorknob
added 280 characters in body
Source Link
Justin
  • 21.4k
  • 9
  • 68
  • 117

#Read from STDIN

GolfScript can read from stdin:

"#{STDIN.read}"
"#{STDIN.read}"

This will continue reading from STDIN until the EOF is reached. Alternatively:

"#{STDIN.gets}"
"#{STDIN.gets}"

or

"#{STDIN.readline}"
"#{STDIN.readline}"

Other things available:

"#{STDIN.readlines}"
"#{STDIN.readchar}"
"#{STDIN.readbyte}"
"#{STDIN.readpartial(int)}" # int is any integer
getbyte
getc
gets([sep])
gets(limit)
gets(sep, limit)
inspect # perhaps useful for an underhanded contest
isatty
read([length])
readbyte
readchar
readline([sep])
readline(limit)
readline(sep, limit)
readlines([sep])
readlines(limit)
readlines(sep, limit)
readpartial(maxlen [, outbuf])

For each of these, they can only be used once (and also once for each change of the parameter, also once more with empty parentheses); after that, the original value is what you'll get instead of a new value.

#Read from STDIN

GolfScript can read from stdin:

"#{STDIN.read}"

This will continue reading from STDIN until the EOF is reached. Alternatively:

"#{STDIN.gets}"

or

"#{STDIN.readline}"

Other things available:

"#{STDIN.readlines}"
"#{STDIN.readchar}"
"#{STDIN.readbyte}"
"#{STDIN.readpartial(int)}" # int is any integer

For each of these, they can only be used once (and also once for each change of the parameter); after that, the original value is what you'll get instead of a new value.

#Read from STDIN

GolfScript can read from stdin:

"#{STDIN.read}"

This will continue reading from STDIN until the EOF is reached. Alternatively:

"#{STDIN.gets}"

or

"#{STDIN.readline}"

Other things available:

getbyte
getc
gets([sep])
gets(limit)
gets(sep, limit)
inspect # perhaps useful for an underhanded contest
isatty
read([length])
readbyte
readchar
readline([sep])
readline(limit)
readline(sep, limit)
readlines([sep])
readlines(limit)
readlines(sep, limit)
readpartial(maxlen [, outbuf])

For each of these, they can only be used once (and also once for each change of the parameter, also once more with empty parentheses); after that, the original value is what you'll get instead of a new value.

added 24 characters in body
Source Link
Justin
  • 21.4k
  • 9
  • 68
  • 117

#Read from STDIN

GolfScript can read from stdin:

"#{STDIN.read}"

This will continue reading from STDIN until the EOF is reached. Alternatively:

"#{STDIN.readlinegets}"

This reads only one line from STDIN. This will only read the first line, so with "#{STDIN.readline}""#{STDIN.readline}" and an input ofor

apple
banana "#{STDIN.readline}"

the output isOther things available:

apple"#{STDIN.readlines}"
apple"#{STDIN.readchar}"
"#{STDIN.readbyte}"
"#{STDIN.readpartial(int)}" # int is any integer

For each of these, they can only be used once (and also once for each change of the parameter); after that, the original value is what you'll get instead of a new value.

#Read from STDIN

GolfScript can read from stdin:

"#{STDIN.read}"

This will continue reading from STDIN until the EOF is reached. Alternatively:

"#{STDIN.readline}"

This reads only one line from STDIN. This will only read the first line, so with "#{STDIN.readline}""#{STDIN.readline}" and an input of

apple
banana 

the output is

apple
apple

#Read from STDIN

GolfScript can read from stdin:

"#{STDIN.read}"

This will continue reading from STDIN until the EOF is reached. Alternatively:

"#{STDIN.gets}"

or

"#{STDIN.readline}"

Other things available:

"#{STDIN.readlines}"
"#{STDIN.readchar}"
"#{STDIN.readbyte}"
"#{STDIN.readpartial(int)}" # int is any integer

For each of these, they can only be used once (and also once for each change of the parameter); after that, the original value is what you'll get instead of a new value.

added 169 characters in body
Source Link
Justin
  • 21.4k
  • 9
  • 68
  • 117
Loading
Source Link
Justin
  • 21.4k
  • 9
  • 68
  • 117
Loading

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