Comparison of programming languages (basic instructions): Difference between revisions

Content deleted Content added
Standard stream I/O: syntaxhighlight
Line 3,108:
|-
| [[Java (programming language)|Java]]
| <code><nowikisyntaxhighlight lang="java" inline>x = System.in.read();</nowiki></codesyntaxhighlight><br/>or<br/><code><nowikisyntaxhighlight lang="java" inline>x = new Scanner(System.in).nextInt();</nowiki></codesyntaxhighlight><br/>or<br/><code><nowikisyntaxhighlight lang="java" inline>x = new Scanner(System.in).nextLine();</nowiki></codesyntaxhighlight>
| <code>System.out.print(''x'');</code><br/>or<br/><code>System.out.[[printf]](''format'', ''x'');</code><br/>or<br/><code>System.out.println(''x'');</code>
| <code>System.err.print(''x'');</code><br/>or<br/><code>System.err.[[printf]](''format'', ''x'');</code><br/>or<br/><code>System.err.println(''x'');</code>
|-
| [[Go (programming language)|Go]]
| <code>fmt.Scan(&''x'')</code><br/>or<br/><code>fmt.[[Scanf]](''format'', &''x'')</code><br/>or<br/><code><nowikisyntaxhighlight lang="go" inline>x = bufio.NewReader(os.Stdin).ReadString('\n')</nowiki></codesyntaxhighlight>
| <code>fmt.Println(''x'')</code><br/>or<br/><code>fmt.[[Printf]](''format'', ''x'')</code>
| <code>fmt.Fprintln(os{{Not a typo|.}}Stderr, x)</code><br/>or<br/><code>fmt.[[Fprintf]](os{{Not a typo|.}}Stderr, ''format'', ''x'')</code>
Line 3,138:
|-
| [[Common Lisp]]
| <code><nowikisyntaxhighlight lang="lisp" inline>(setf x (read-line))</nowiki></codesyntaxhighlight>
| <code>(princ ''x'')</code><br/>or<br/><code>(format t ''format x'')</code>
| <codesyntaxhighlight lang="lisp" inline>(princ x *error-output*)</codesyntaxhighlight><br/>or<br/><code>{{codett|(format *error-output*|lisp}} ''format x'')</code>
|-
| [[Scheme (programming language)|Scheme]] ([[R6RS|R<sup>6</sup>RS]])
| <codesyntaxhighlight lang="scheme" inline>(define x (read-line))</codesyntaxhighlight>
| <code>(display ''x'')</code><br/>or<br/><code>{{codett|(format #t|scheme}} ''format x'')</code>
| <codesyntaxhighlight lang="scheme" inline>(display x (current-error-port))</codesyntaxhighlight><br/>or<br/><code>{{codett|(format (current-error-port)|scheme}} ''format x'')</code>
|-
| [[ISLISP]]
Line 3,208:
|-
| [[Raku (programming language)|Raku]]
| <code><nowikisyntaxhighlight lang="raku" inline>$x = $*IN.get;</nowiki></codesyntaxhighlight>
| <code>''x''.print</code><br/>or<br/><code>''x''.say</code>
| <code>''x''.note</code><br/>or<br/><codesyntaxhighlight lang="raku" inline>$*ERR.print(x)</codesyntaxhighlight><br/>or<br/><codesyntaxhighlight lang="raku" inline>$*ERR.say(x)</codesyntaxhighlight>
|-
| [[Ruby (programming language)|Ruby]]
Line 3,218:
|-
| [[Windows PowerShell]]
| <code>''$x'' = Read-Host«« -Prompt» ''text''»;</code><br/>or<br/><code><nowikisyntaxhighlight lang="ps1" inline>$x = [Console]::Read();</nowiki></codesyntaxhighlight><br/>or<br/><code><nowikisyntaxhighlight lang="ps1" inline>$x = [Console]::ReadLine()</nowiki></codesyntaxhighlight>
| <code>''x'';</code><br/>or<br/><code>Write-Output ''x'';</code><br/>or<br/><code>echo ''x''</code>
| <code>Write-Error ''x''</code>
Line 3,228:
|-
| [[F Sharp (programming language)|F#]]
| <code><nowikisyntaxhighlight lang="f#" inline>let x = System.Console.ReadLine()</nowiki></codesyntaxhighlight>
| <code>[[printf]] ''format x ...''</code><br/>or<br/><code>[[printf]]n ''format x ...''</code>
| <code>[[fprintf|eprintf]] ''format x ...''</code><br/>or<br/><code>[[fprintf|eprintf]]n ''format x ...''</code>
|-
| [[Standard ML]]
| <code><nowikisyntaxhighlight lang="sml" inline>val str = TextIO.inputLIne TextIO.stdIn</nowiki></codesyntaxhighlight>
| <code>print ''str''</code>
| <code>{{codett|TextIO.output (TextIO.stdErr,|sml}}'' str'')</code>