task_url stringlengths 30 116 | task_name stringlengths 2 86 | task_description stringlengths 0 14.4k | language_url stringlengths 2 53 | language_name stringlengths 1 52 | code stringlengths 0 61.9k |
|---|---|---|---|---|---|
http://rosettacode.org/wiki/Character_codes | Character codes |
Task
Given a character value in your language, print its code (could be ASCII code, Unicode code, or whatever your language uses).
Example
The character 'a' (lowercase letter A) has a code of 97 in ASCII (as well as Unicode, as ASCII forms the beginning of Unicode).
Conversely, given a code, print out... | #Nanoquery | Nanoquery | println ord("a")
println chr(97)
println ord("π")
println chr(960) |
http://rosettacode.org/wiki/Collections | Collections | This task has been clarified. Its programming examples are in need of review to ensure that they still fit the requirements of the task.
Collections are abstractions to represent sets of values.
In statically-typed languages, the values are typically of a common data type.
Task
Create a collection, and add a fe... | #Tcl | Tcl | set c [list] ;# create an empty list
# fill it
lappend c 10 11 13
set c [linsert $c 2 "twelve goes here"]
# iterate over it
foreach elem $c {puts $elem}
# pass to a proc
proc show_size {l} {
puts [llength $l]
}
show_size $c |
http://rosettacode.org/wiki/Check_that_file_exists | Check that file exists | Task
Verify that a file called input.txt and a directory called docs exist.
This should be done twice:
once for the current working directory, and
once for a file and a directory in the filesystem root.
Optional criteria (May 2015): verify it works with:
zero-length files
an ... | #QB64 | QB64 | $NOPREFIX
PRINT DIREXISTS("docs")
PRINT DIREXISTS("\docs")
PRINT FILEEXISTS("input.txt")
PRINT FILEEXISTS("\input.txt") |
http://rosettacode.org/wiki/Check_that_file_exists | Check that file exists | Task
Verify that a file called input.txt and a directory called docs exist.
This should be done twice:
once for the current working directory, and
once for a file and a directory in the filesystem root.
Optional criteria (May 2015): verify it works with:
zero-length files
an ... | #R | R | file.exists("input.txt")
file.exists("/input.txt")
file.exists("docs")
file.exists("/docs")
# or
file.exists("input.txt", "/input.txt", "docs", "/docs") |
http://rosettacode.org/wiki/Character_codes | Character codes |
Task
Given a character value in your language, print its code (could be ASCII code, Unicode code, or whatever your language uses).
Example
The character 'a' (lowercase letter A) has a code of 97 in ASCII (as well as Unicode, as ASCII forms the beginning of Unicode).
Conversely, given a code, print out... | #Neko | Neko | // An 'a' and a 'b'
var s = "a";
var c = 98;
var h = " ";
$print("Character code for 'a': ", $sget(s, 0), "\n");
$sset(h, 0, c);
$print("Character code ", c, ": ", h, "\n"); |
http://rosettacode.org/wiki/Character_codes | Character codes |
Task
Given a character value in your language, print its code (could be ASCII code, Unicode code, or whatever your language uses).
Example
The character 'a' (lowercase letter A) has a code of 97 in ASCII (as well as Unicode, as ASCII forms the beginning of Unicode).
Conversely, given a code, print out... | #NESL | NESL | char_code(`a);
it = 97 : int |
http://rosettacode.org/wiki/Collections | Collections | This task has been clarified. Its programming examples are in need of review to ensure that they still fit the requirements of the task.
Collections are abstractions to represent sets of values.
In statically-typed languages, the values are typically of a common data type.
Task
Create a collection, and add a fe... | #TUSCRIPT | TUSCRIPT |
$$ MODE TUSCRIPT
collection=*
DATA apple
DATA banana
DATA orange
morestuff=*
DATA peaches
DATA apple
collection=APPEND(collection,morestuff)
TRACE *collection
|
http://rosettacode.org/wiki/Check_that_file_exists | Check that file exists | Task
Verify that a file called input.txt and a directory called docs exist.
This should be done twice:
once for the current working directory, and
once for a file and a directory in the filesystem root.
Optional criteria (May 2015): verify it works with:
zero-length files
an ... | #Racket | Racket |
#lang racket
;; here
(file-exists? "input.txt")
(file-exists? "docs")
;; in the root
(file-exists? "/input.txt")
(file-exists? "/docs")
;; or in the root with relative paths
(parameterize ([current-directory "/"])
(and (file-exists? "input.txt")
(file-exists? "docs")))
|
http://rosettacode.org/wiki/Check_that_file_exists | Check that file exists | Task
Verify that a file called input.txt and a directory called docs exist.
This should be done twice:
once for the current working directory, and
once for a file and a directory in the filesystem root.
Optional criteria (May 2015): verify it works with:
zero-length files
an ... | #Raku | Raku |
my $path = "/etc/passwd";
say $path.IO.e ?? "Exists" !! "Does not exist";
given $path.IO {
when :d { say "$path is a directory"; }
when :f { say "$path is a regular file"; }
when :e { say "$path is neither a directory nor a file, but it does exist"; }
default { say "$path does not exist" }
} |
http://rosettacode.org/wiki/Character_codes | Character codes |
Task
Given a character value in your language, print its code (could be ASCII code, Unicode code, or whatever your language uses).
Example
The character 'a' (lowercase letter A) has a code of 97 in ASCII (as well as Unicode, as ASCII forms the beginning of Unicode).
Conversely, given a code, print out... | #NetRexx | NetRexx | /* NetRexx */
options replace format comments java crossref symbols nobinary
runSample(arg)
return
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
method runSample(arg) private static
-- create some sample data: character, hex and unicode
samp = ' ' || 'a'.sequence('e') || '$' |... |
http://rosettacode.org/wiki/Character_codes | Character codes |
Task
Given a character value in your language, print its code (could be ASCII code, Unicode code, or whatever your language uses).
Example
The character 'a' (lowercase letter A) has a code of 97 in ASCII (as well as Unicode, as ASCII forms the beginning of Unicode).
Conversely, given a code, print out... | #Nim | Nim | echo ord('a') # echoes 97
echo chr(97) # echoes a
import unicode
echo int("π".runeAt(0)) # echoes 960
echo Rune(960) # echoes π |
http://rosettacode.org/wiki/Collections | Collections | This task has been clarified. Its programming examples are in need of review to ensure that they still fit the requirements of the task.
Collections are abstractions to represent sets of values.
In statically-typed languages, the values are typically of a common data type.
Task
Create a collection, and add a fe... | #UNIX_Shell | UNIX Shell | a_index=(one two three) # create an array with a few elements
a_index+=(four five) # append some elements
a_index[9]=ten # add a specific index
for elem in "${a_index[@]}"; do # interate over the elements
echo "$elem"
done
for idx in "${!a_index[@]}"; do # interate over ... |
http://rosettacode.org/wiki/Check_that_file_exists | Check that file exists | Task
Verify that a file called input.txt and a directory called docs exist.
This should be done twice:
once for the current working directory, and
once for a file and a directory in the filesystem root.
Optional criteria (May 2015): verify it works with:
zero-length files
an ... | #Raven | Raven | 'input.txt' exists if 'input.txt exists' print
'/input.txt' exists if '/input.txt exists' print
'docs' isdir if 'docs exists and is a directory' print
'/docs' isdir if '/docs exists and is a directory' print |
http://rosettacode.org/wiki/Check_that_file_exists | Check that file exists | Task
Verify that a file called input.txt and a directory called docs exist.
This should be done twice:
once for the current working directory, and
once for a file and a directory in the filesystem root.
Optional criteria (May 2015): verify it works with:
zero-length files
an ... | #REBOL | REBOL | exists? %input.txt
exists? %docs/
exists? %/input.txt
exists? %/docs/ |
http://rosettacode.org/wiki/Character_codes | Character codes |
Task
Given a character value in your language, print its code (could be ASCII code, Unicode code, or whatever your language uses).
Example
The character 'a' (lowercase letter A) has a code of 97 in ASCII (as well as Unicode, as ASCII forms the beginning of Unicode).
Conversely, given a code, print out... | #NS-HUBASIC | NS-HUBASIC | 10 PRINT CODE "A"
20 PRINT CHR$(38) |
http://rosettacode.org/wiki/Character_codes | Character codes |
Task
Given a character value in your language, print its code (could be ASCII code, Unicode code, or whatever your language uses).
Example
The character 'a' (lowercase letter A) has a code of 97 in ASCII (as well as Unicode, as ASCII forms the beginning of Unicode).
Conversely, given a code, print out... | #Oberon-2 | Oberon-2 | MODULE Ascii;
IMPORT Out;
VAR
c: CHAR;
d: INTEGER;
BEGIN
c := CHR(97);
d := ORD("a");
Out.Int(d,3);Out.Ln;
Out.Char(c);Out.Ln
END Ascii. |
http://rosettacode.org/wiki/Collections | Collections | This task has been clarified. Its programming examples are in need of review to ensure that they still fit the requirements of the task.
Collections are abstractions to represent sets of values.
In statically-typed languages, the values are typically of a common data type.
Task
Create a collection, and add a fe... | #Ursala | Ursala | x = <1,5,6>
y = <'foo','bar'>
z = 3:<6,8> |
http://rosettacode.org/wiki/Check_that_file_exists | Check that file exists | Task
Verify that a file called input.txt and a directory called docs exist.
This should be done twice:
once for the current working directory, and
once for a file and a directory in the filesystem root.
Optional criteria (May 2015): verify it works with:
zero-length files
an ... | #Red | Red | exists? %input.txt
exists? %docs/
exists? %/c/input.txt
exists? %/c/docs/
exists? %//input.txt
exists? %//docs/
>> exists? %`Abdu'l-Bahá.txt
== true |
http://rosettacode.org/wiki/Check_that_file_exists | Check that file exists | Task
Verify that a file called input.txt and a directory called docs exist.
This should be done twice:
once for the current working directory, and
once for a file and a directory in the filesystem root.
Optional criteria (May 2015): verify it works with:
zero-length files
an ... | #REXX | REXX | /*REXX program creates a new empty file and directory in current directory and root dir.*/
fn= 'input.txt' /*default name of a file. */
dn= 'docs' /*default name of a directory (folder).*/
@.1= 'current directory'; @.2= 'root directory... |
http://rosettacode.org/wiki/Character_codes | Character codes |
Task
Given a character value in your language, print its code (could be ASCII code, Unicode code, or whatever your language uses).
Example
The character 'a' (lowercase letter A) has a code of 97 in ASCII (as well as Unicode, as ASCII forms the beginning of Unicode).
Conversely, given a code, print out... | #Objeck | Objeck | 'a'->As(Int)->PrintLine();
97->As(Char)->PrintLine(); |
http://rosettacode.org/wiki/Character_codes | Character codes |
Task
Given a character value in your language, print its code (could be ASCII code, Unicode code, or whatever your language uses).
Example
The character 'a' (lowercase letter A) has a code of 97 in ASCII (as well as Unicode, as ASCII forms the beginning of Unicode).
Conversely, given a code, print out... | #Object_Pascal | Object Pascal | Printf.printf "%d\n" (int_of_char 'a'); (* prints "97" *)
Printf.printf "%c\n" (char_of_int 97); (* prints "a" *) |
http://rosettacode.org/wiki/Collections | Collections | This task has been clarified. Its programming examples are in need of review to ensure that they still fit the requirements of the task.
Collections are abstractions to represent sets of values.
In statically-typed languages, the values are typically of a common data type.
Task
Create a collection, and add a fe... | #V | V | [4 3 2 1] 5 swap cons
=[5 4 3 2 1] |
http://rosettacode.org/wiki/Check_that_file_exists | Check that file exists | Task
Verify that a file called input.txt and a directory called docs exist.
This should be done twice:
once for the current working directory, and
once for a file and a directory in the filesystem root.
Optional criteria (May 2015): verify it works with:
zero-length files
an ... | #Ring | Ring |
aFile = "C:\Ring\ReadMe.txt"
see aFile
if Fexists(aFile) see " exists" + nl
else see " doesn't exist" + nl ok
|
http://rosettacode.org/wiki/Check_that_file_exists | Check that file exists | Task
Verify that a file called input.txt and a directory called docs exist.
This should be done twice:
once for the current working directory, and
once for a file and a directory in the filesystem root.
Optional criteria (May 2015): verify it works with:
zero-length files
an ... | #RLaB | RLaB |
>> isdir("docs")
0
>> isfile("input.txt")
0
|
http://rosettacode.org/wiki/Character_codes | Character codes |
Task
Given a character value in your language, print its code (could be ASCII code, Unicode code, or whatever your language uses).
Example
The character 'a' (lowercase letter A) has a code of 97 in ASCII (as well as Unicode, as ASCII forms the beginning of Unicode).
Conversely, given a code, print out... | #OCaml | OCaml | Printf.printf "%d\n" (int_of_char 'a'); (* prints "97" *)
Printf.printf "%c\n" (char_of_int 97); (* prints "a" *) |
http://rosettacode.org/wiki/Character_codes | Character codes |
Task
Given a character value in your language, print its code (could be ASCII code, Unicode code, or whatever your language uses).
Example
The character 'a' (lowercase letter A) has a code of 97 in ASCII (as well as Unicode, as ASCII forms the beginning of Unicode).
Conversely, given a code, print out... | #Oforth | Oforth | 'a' println |
http://rosettacode.org/wiki/Collections | Collections | This task has been clarified. Its programming examples are in need of review to ensure that they still fit the requirements of the task.
Collections are abstractions to represent sets of values.
In statically-typed languages, the values are typically of a common data type.
Task
Create a collection, and add a fe... | #VBA | VBA | Dim coll As New Collection
coll.Add "apple"
coll.Add "banana" |
http://rosettacode.org/wiki/Check_that_file_exists | Check that file exists | Task
Verify that a file called input.txt and a directory called docs exist.
This should be done twice:
once for the current working directory, and
once for a file and a directory in the filesystem root.
Optional criteria (May 2015): verify it works with:
zero-length files
an ... | #Ruby | Ruby | File.file?("input.txt")
File.file?("/input.txt")
File.directory?("docs")
File.directory?("/docs") |
http://rosettacode.org/wiki/Character_codes | Character codes |
Task
Given a character value in your language, print its code (could be ASCII code, Unicode code, or whatever your language uses).
Example
The character 'a' (lowercase letter A) has a code of 97 in ASCII (as well as Unicode, as ASCII forms the beginning of Unicode).
Conversely, given a code, print out... | #OpenEdge.2FProgress | OpenEdge/Progress | MESSAGE
CHR(97) SKIP
ASC("a")
VIEW-AS ALERT-BOX. |
http://rosettacode.org/wiki/Collections | Collections | This task has been clarified. Its programming examples are in need of review to ensure that they still fit the requirements of the task.
Collections are abstractions to represent sets of values.
In statically-typed languages, the values are typically of a common data type.
Task
Create a collection, and add a fe... | #Vim_Script | Vim Script | Dim toys As New List(Of String)
toys.Add("Car")
toys.Add("Boat")
toys.Add("Train") |
http://rosettacode.org/wiki/Check_that_file_exists | Check that file exists | Task
Verify that a file called input.txt and a directory called docs exist.
This should be done twice:
once for the current working directory, and
once for a file and a directory in the filesystem root.
Optional criteria (May 2015): verify it works with:
zero-length files
an ... | #Run_BASIC | Run BASIC | files #f,"input.txt"
if #f hasanswer() = 1 then print "File does not exist"
files #f,"docs"
if #f hasanswer() = 1 then print "File does not exist"
if #f isDir() = 0 then print "This is a directory"
|
http://rosettacode.org/wiki/Check_that_file_exists | Check that file exists | Task
Verify that a file called input.txt and a directory called docs exist.
This should be done twice:
once for the current working directory, and
once for a file and a directory in the filesystem root.
Optional criteria (May 2015): verify it works with:
zero-length files
an ... | #Rust | Rust | use std::fs;
fn main() {
for file in ["input.txt", "docs", "/input.txt", "/docs"].iter() {
match fs::metadata(file) {
Ok(attr) => {
if attr.is_dir() {
println!("{} is a directory", file);
}else {
println!("{} is a file", f... |
http://rosettacode.org/wiki/Character_codes | Character codes |
Task
Given a character value in your language, print its code (could be ASCII code, Unicode code, or whatever your language uses).
Example
The character 'a' (lowercase letter A) has a code of 97 in ASCII (as well as Unicode, as ASCII forms the beginning of Unicode).
Conversely, given a code, print out... | #Oz | Oz | {System.show &a} %% prints "97"
{System.showInfo [97]} %% prints "a" |
http://rosettacode.org/wiki/Character_codes | Character codes |
Task
Given a character value in your language, print its code (could be ASCII code, Unicode code, or whatever your language uses).
Example
The character 'a' (lowercase letter A) has a code of 97 in ASCII (as well as Unicode, as ASCII forms the beginning of Unicode).
Conversely, given a code, print out... | #PARI.2FGP | PARI/GP | print(Vecsmall("a")[1]);
print(Strchr([72, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108, 100, 33])) |
http://rosettacode.org/wiki/Collections | Collections | This task has been clarified. Its programming examples are in need of review to ensure that they still fit the requirements of the task.
Collections are abstractions to represent sets of values.
In statically-typed languages, the values are typically of a common data type.
Task
Create a collection, and add a fe... | #Visual_Basic_.NET | Visual Basic .NET | Dim toys As New List(Of String)
toys.Add("Car")
toys.Add("Boat")
toys.Add("Train") |
http://rosettacode.org/wiki/Check_that_file_exists | Check that file exists | Task
Verify that a file called input.txt and a directory called docs exist.
This should be done twice:
once for the current working directory, and
once for a file and a directory in the filesystem root.
Optional criteria (May 2015): verify it works with:
zero-length files
an ... | #Scala | Scala | import java.nio.file.{ Files, FileSystems }
object FileExistsTest extends App {
val defaultFS = FileSystems.getDefault()
val separator = defaultFS.getSeparator()
def test(filename: String) {
val path = defaultFS.getPath(filename)
println(s"The following ${if (Files.isDirectory(path)) "directory" e... |
http://rosettacode.org/wiki/Character_codes | Character codes |
Task
Given a character value in your language, print its code (could be ASCII code, Unicode code, or whatever your language uses).
Example
The character 'a' (lowercase letter A) has a code of 97 in ASCII (as well as Unicode, as ASCII forms the beginning of Unicode).
Conversely, given a code, print out... | #Pascal | Pascal | writeln(ord('a'));
writeln(chr(97)); |
http://rosettacode.org/wiki/Character_codes | Character codes |
Task
Given a character value in your language, print its code (could be ASCII code, Unicode code, or whatever your language uses).
Example
The character 'a' (lowercase letter A) has a code of 97 in ASCII (as well as Unicode, as ASCII forms the beginning of Unicode).
Conversely, given a code, print out... | #Perl | Perl | use strict;
use warnings;
use utf8;
binmode(STDOUT, ':utf8');
use Encode;
use Unicode::UCD 'charinfo';
use List::AllUtils qw(zip natatime);
for my $c (split //, 'AΑА薵') {
my $o = ord $c;
my $utf8 = join '', map { sprintf "%x ", ord } split //, Encode::encode("utf8", $c);
my $iterator = natatime 2, zip
... |
http://rosettacode.org/wiki/Collections | Collections | This task has been clarified. Its programming examples are in need of review to ensure that they still fit the requirements of the task.
Collections are abstractions to represent sets of values.
In statically-typed languages, the values are typically of a common data type.
Task
Create a collection, and add a fe... | #Visual_FoxPro | Visual FoxPro |
LOCAL loColl As Collection, o, a1, a2, a3
a1 = CREATEOBJECT("animal", "dog", 4)
a2 = CREATEOBJECT("animal", "chicken", 2)
a3 = CREATEOBJECT("animal", "snake", 0)
loColl = NEWOBJECT("Collection")
loColl.Add(a1)
loColl.Add(a2)
loColl.Add(a3)
FOR EACH o IN loColl FOXOBJECT
? o.Name, o.Legs
ENDFOR
DEFINE CLASS a... |
http://rosettacode.org/wiki/Check_that_file_exists | Check that file exists | Task
Verify that a file called input.txt and a directory called docs exist.
This should be done twice:
once for the current working directory, and
once for a file and a directory in the filesystem root.
Optional criteria (May 2015): verify it works with:
zero-length files
an ... | #Scheme | Scheme | (file-exists? filename) |
http://rosettacode.org/wiki/Check_that_file_exists | Check that file exists | Task
Verify that a file called input.txt and a directory called docs exist.
This should be done twice:
once for the current working directory, and
once for a file and a directory in the filesystem root.
Optional criteria (May 2015): verify it works with:
zero-length files
an ... | #Seed7 | Seed7 | $ include "seed7_05.s7i";
const proc: main is func
begin
writeln(fileType("input.txt") = FILE_REGULAR);
writeln(fileType("/input.txt") = FILE_REGULAR);
writeln(fileType("docs") = FILE_DIR);
writeln(fileType("/docs") = FILE_DIR);
end func; |
http://rosettacode.org/wiki/Character_codes | Character codes |
Task
Given a character value in your language, print its code (could be ASCII code, Unicode code, or whatever your language uses).
Example
The character 'a' (lowercase letter A) has a code of 97 in ASCII (as well as Unicode, as ASCII forms the beginning of Unicode).
Conversely, given a code, print out... | #Phix | Phix | ?'A'
puts(1,65)
|
http://rosettacode.org/wiki/Character_codes | Character codes |
Task
Given a character value in your language, print its code (could be ASCII code, Unicode code, or whatever your language uses).
Example
The character 'a' (lowercase letter A) has a code of 97 in ASCII (as well as Unicode, as ASCII forms the beginning of Unicode).
Conversely, given a code, print out... | #Phixmonti | Phixmonti | 'a' print nl
97 tochar print |
http://rosettacode.org/wiki/Collections | Collections | This task has been clarified. Its programming examples are in need of review to ensure that they still fit the requirements of the task.
Collections are abstractions to represent sets of values.
In statically-typed languages, the values are typically of a common data type.
Task
Create a collection, and add a fe... | #Wren | Wren | var list = [] // Empty Array
list = [1, 2, 3, 4]
list.add(5)
list.clear()
list = [0] * 10
list.count // 10
var map = {}
map["key"] = "value"
map[3] = 31
map.count // 2
map.clear()
for (e in map.keys) {
// Do stuff
} |
http://rosettacode.org/wiki/Check_that_file_exists | Check that file exists | Task
Verify that a file called input.txt and a directory called docs exist.
This should be done twice:
once for the current working directory, and
once for a file and a directory in the filesystem root.
Optional criteria (May 2015): verify it works with:
zero-length files
an ... | #SenseTalk | SenseTalk |
put file "input.txt" exists
put folder "docs" exists
put file "/input.txt" exists
put there is a folder "/docs"
|
http://rosettacode.org/wiki/Check_that_file_exists | Check that file exists | Task
Verify that a file called input.txt and a directory called docs exist.
This should be done twice:
once for the current working directory, and
once for a file and a directory in the filesystem root.
Optional criteria (May 2015): verify it works with:
zero-length files
an ... | #Sidef | Sidef | # Here
say (Dir.cwd + %f'input.txt' -> is_file);
say (Dir.cwd + %d'docs' -> is_dir);
# Root
say (Dir.root + %f'input.txt' -> is_file);
say (Dir.root + %d'docs' -> is_dir); |
http://rosettacode.org/wiki/Character_codes | Character codes |
Task
Given a character value in your language, print its code (could be ASCII code, Unicode code, or whatever your language uses).
Example
The character 'a' (lowercase letter A) has a code of 97 in ASCII (as well as Unicode, as ASCII forms the beginning of Unicode).
Conversely, given a code, print out... | #PHP | PHP | echo ord('a'), "\n"; // prints "97"
echo chr(97), "\n"; // prints "a" |
http://rosettacode.org/wiki/Character_codes | Character codes |
Task
Given a character value in your language, print its code (could be ASCII code, Unicode code, or whatever your language uses).
Example
The character 'a' (lowercase letter A) has a code of 97 in ASCII (as well as Unicode, as ASCII forms the beginning of Unicode).
Conversely, given a code, print out... | #Picat | Picat | main =>
println(chr(97)),
println(ord('a')),
println(ord(a)). |
http://rosettacode.org/wiki/Collections | Collections | This task has been clarified. Its programming examples are in need of review to ensure that they still fit the requirements of the task.
Collections are abstractions to represent sets of values.
In statically-typed languages, the values are typically of a common data type.
Task
Create a collection, and add a fe... | #Z80_Assembly | Z80 Assembly | List:
byte 1,2,3,4,5 |
http://rosettacode.org/wiki/Check_that_file_exists | Check that file exists | Task
Verify that a file called input.txt and a directory called docs exist.
This should be done twice:
once for the current working directory, and
once for a file and a directory in the filesystem root.
Optional criteria (May 2015): verify it works with:
zero-length files
an ... | #Slate | Slate | (File newNamed: 'input.txt') exists
(File newNamed: '/input.txt') exists
(Directory root / 'input.txt') exists
(Directory newNamed: 'docs') exists
(Directory newNamed: '/docs') exists |
http://rosettacode.org/wiki/Check_that_file_exists | Check that file exists | Task
Verify that a file called input.txt and a directory called docs exist.
This should be done twice:
once for the current working directory, and
once for a file and a directory in the filesystem root.
Optional criteria (May 2015): verify it works with:
zero-length files
an ... | #Smalltalk | Smalltalk | FileDirectory new fileExists: 'c:\serial'.
(FileDirectory on: 'c:\') directoryExists: 'docs'. |
http://rosettacode.org/wiki/Character_codes | Character codes |
Task
Given a character value in your language, print its code (could be ASCII code, Unicode code, or whatever your language uses).
Example
The character 'a' (lowercase letter A) has a code of 97 in ASCII (as well as Unicode, as ASCII forms the beginning of Unicode).
Conversely, given a code, print out... | #PicoLisp | PicoLisp | : (char "a")
-> 97
: (char "字")
-> 23383
: (char 23383)
-> "字"
: (chop "文字")
-> ("文" "字")
: (mapcar char @)
-> (25991 23383) |
http://rosettacode.org/wiki/Character_codes | Character codes |
Task
Given a character value in your language, print its code (could be ASCII code, Unicode code, or whatever your language uses).
Example
The character 'a' (lowercase letter A) has a code of 97 in ASCII (as well as Unicode, as ASCII forms the beginning of Unicode).
Conversely, given a code, print out... | #PL.2FI | PL/I | declare 1 u union,
2 c character (1),
2 i fixed binary (8) unsigned;
c = 'a'; put skip list (i); /* prints 97 */
i = 97; put skip list (c); /* prints 'a' */ |
http://rosettacode.org/wiki/Collections | Collections | This task has been clarified. Its programming examples are in need of review to ensure that they still fit the requirements of the task.
Collections are abstractions to represent sets of values.
In statically-typed languages, the values are typically of a common data type.
Task
Create a collection, and add a fe... | #zkl | zkl | Lists: L(1,2,3).append(4); //-->L(1,2,3,4), mutable list
Read only list: ROList(1,2,3).append(4); // creates two lists
Bit bucket: Data(0,Int,1,2,3) // three bytes
The "Int" means treat contents as a byte stream
Data(0,Int,"foo ","bar") //-->7 bytes
Data(0,Int,"foo ").append("bar") //ditto
Data(0,Int,"foo\n... |
http://rosettacode.org/wiki/Check_that_file_exists | Check that file exists | Task
Verify that a file called input.txt and a directory called docs exist.
This should be done twice:
once for the current working directory, and
once for a file and a directory in the filesystem root.
Optional criteria (May 2015): verify it works with:
zero-length files
an ... | #Standard_ML | Standard ML | OS.FileSys.access ("input.txt", []);
OS.FileSys.access ("docs", []);
OS.FileSys.access ("/input.txt", []);
OS.FileSys.access ("/docs", []); |
http://rosettacode.org/wiki/Check_that_file_exists | Check that file exists | Task
Verify that a file called input.txt and a directory called docs exist.
This should be done twice:
once for the current working directory, and
once for a file and a directory in the filesystem root.
Optional criteria (May 2015): verify it works with:
zero-length files
an ... | #Stata | Stata | mata
fileexists("input.txt")
direxists("docs")
end |
http://rosettacode.org/wiki/Character_codes | Character codes |
Task
Given a character value in your language, print its code (could be ASCII code, Unicode code, or whatever your language uses).
Example
The character 'a' (lowercase letter A) has a code of 97 in ASCII (as well as Unicode, as ASCII forms the beginning of Unicode).
Conversely, given a code, print out... | #PowerShell | PowerShell | $char = [convert]::toChar(0x2f) #=> / |
http://rosettacode.org/wiki/Check_that_file_exists | Check that file exists | Task
Verify that a file called input.txt and a directory called docs exist.
This should be done twice:
once for the current working directory, and
once for a file and a directory in the filesystem root.
Optional criteria (May 2015): verify it works with:
zero-length files
an ... | #Tcl | Tcl | if { [file exists "input.txt"] } {
puts "input.txt exists"
}
if { [file exists [file nativename "/input.txt"]] } {
puts "/input.txt exists"
}
if { [file isdirectory "docs"] } {
puts "docs exists and is a directory"
}
if { [file isdirectory [file nativename "/docs"]] } {
puts "/docs exists and is... |
http://rosettacode.org/wiki/Character_codes | Character codes |
Task
Given a character value in your language, print its code (could be ASCII code, Unicode code, or whatever your language uses).
Example
The character 'a' (lowercase letter A) has a code of 97 in ASCII (as well as Unicode, as ASCII forms the beginning of Unicode).
Conversely, given a code, print out... | #Prolog | Prolog | ?- char_code(a, X).
X = 97.
?- char_code(X, 97).
X = a. |
http://rosettacode.org/wiki/Check_that_file_exists | Check that file exists | Task
Verify that a file called input.txt and a directory called docs exist.
This should be done twice:
once for the current working directory, and
once for a file and a directory in the filesystem root.
Optional criteria (May 2015): verify it works with:
zero-length files
an ... | #Toka | Toka | [ "R" file.open dup 0 <> [ dup file.close ] ifTrue 0 <> ] is exists?
" input.txt" exists? .
" /input.txt" exists? .
" docs" exists? .
" /docs" exists? . |
http://rosettacode.org/wiki/Check_that_file_exists | Check that file exists | Task
Verify that a file called input.txt and a directory called docs exist.
This should be done twice:
once for the current working directory, and
once for a file and a directory in the filesystem root.
Optional criteria (May 2015): verify it works with:
zero-length files
an ... | #True_BASIC | True BASIC | SUB opener (a$)
WHEN EXCEPTION IN
OPEN #1: NAME f$
PRINT f$; " exists"
USE
PRINT f$; " not exists"
END WHEN
CLOSE #1
END SUB
LET f$ = "input.txt"
CALL opener (f$)
LET f$ = "\input.txt"
CALL opener (f$)
LET f$ = "docs\nul"
CALL opener (f$)
LET f$ = "\docs\nul"
CALL opener (f$... |
http://rosettacode.org/wiki/Character_codes | Character codes |
Task
Given a character value in your language, print its code (could be ASCII code, Unicode code, or whatever your language uses).
Example
The character 'a' (lowercase letter A) has a code of 97 in ASCII (as well as Unicode, as ASCII forms the beginning of Unicode).
Conversely, given a code, print out... | #PureBasic | PureBasic | If OpenConsole()
;Results are the same when compiled for Ascii or Unicode
charCode.c = 97
Char.s = "a"
PrintN(Chr(charCode)) ;prints a
PrintN(Str(Asc(Char))) ;prints 97
Print(#CRLF$ + #CRLF$ + "Press ENTER to exit")
Input()
CloseConsole()
EndIf |
http://rosettacode.org/wiki/Check_that_file_exists | Check that file exists | Task
Verify that a file called input.txt and a directory called docs exist.
This should be done twice:
once for the current working directory, and
once for a file and a directory in the filesystem root.
Optional criteria (May 2015): verify it works with:
zero-length files
an ... | #TUSCRIPT | TUSCRIPT |
$$ MODE TUSCRIPT
file="input.txt",directory="docs"
IF (file=='file') THEN
PRINT file, " exists"
ELSE
PRINT/ERROR file," not exists"
ENDIF
IF (directory=='project') THEN
PRINT directory," exists"
ELSE
PRINT/ERROR "directory ",directory," not exists"
ENDIF
|
http://rosettacode.org/wiki/Check_that_file_exists | Check that file exists | Task
Verify that a file called input.txt and a directory called docs exist.
This should be done twice:
once for the current working directory, and
once for a file and a directory in the filesystem root.
Optional criteria (May 2015): verify it works with:
zero-length files
an ... | #UNIX_Shell | UNIX Shell | test -f input.txt
test -f /input.txt
test -d docs
test -d /docs |
http://rosettacode.org/wiki/Character_codes | Character codes |
Task
Given a character value in your language, print its code (could be ASCII code, Unicode code, or whatever your language uses).
Example
The character 'a' (lowercase letter A) has a code of 97 in ASCII (as well as Unicode, as ASCII forms the beginning of Unicode).
Conversely, given a code, print out... | #Python | Python | print ord('a') # prints "97"
print chr(97) # prints "a" |
http://rosettacode.org/wiki/Check_that_file_exists | Check that file exists | Task
Verify that a file called input.txt and a directory called docs exist.
This should be done twice:
once for the current working directory, and
once for a file and a directory in the filesystem root.
Optional criteria (May 2015): verify it works with:
zero-length files
an ... | #Ursa | Ursa | def exists (string filename)
decl file f
try
f.open filename
return true
catch ioerror
return false
end try
end exists |
http://rosettacode.org/wiki/Character_codes | Character codes |
Task
Given a character value in your language, print its code (could be ASCII code, Unicode code, or whatever your language uses).
Example
The character 'a' (lowercase letter A) has a code of 97 in ASCII (as well as Unicode, as ASCII forms the beginning of Unicode).
Conversely, given a code, print out... | #Quackery | Quackery | Welcome to Quackery.
Enter "leave" to leave the shell.
/O> char a
...
Stack: 97
/O> emit
...
a
Stack empty. |
http://rosettacode.org/wiki/Character_codes | Character codes |
Task
Given a character value in your language, print its code (could be ASCII code, Unicode code, or whatever your language uses).
Example
The character 'a' (lowercase letter A) has a code of 97 in ASCII (as well as Unicode, as ASCII forms the beginning of Unicode).
Conversely, given a code, print out... | #R | R | ascii <- as.integer(charToRaw("hello world")); ascii
text <- rawToChar(as.raw(ascii)); text |
http://rosettacode.org/wiki/Check_that_file_exists | Check that file exists | Task
Verify that a file called input.txt and a directory called docs exist.
This should be done twice:
once for the current working directory, and
once for a file and a directory in the filesystem root.
Optional criteria (May 2015): verify it works with:
zero-length files
an ... | #Vala | Vala | int main (string[] args) {
string[] files = {"input.txt", "docs", Path.DIR_SEPARATOR_S + "input.txt", Path.DIR_SEPARATOR_S + "docs"};
foreach (string f in files) {
var file = File.new_for_path (f);
print ("%s exists: %s\n", f, file.query_exists ().to_string ());
}
return 0;
} |
http://rosettacode.org/wiki/Check_that_file_exists | Check that file exists | Task
Verify that a file called input.txt and a directory called docs exist.
This should be done twice:
once for the current working directory, and
once for a file and a directory in the filesystem root.
Optional criteria (May 2015): verify it works with:
zero-length files
an ... | #VBA | VBA |
Option Explicit
Sub Main_File_Exists()
Dim myFile As String, myDirectory As String
myFile = "Abdu'l-Bahá.txt"
myDirectory = "C:\"
Debug.Print File_Exists(myFile, myDirectory)
End Sub
Function File_Exists(F As String, D As String) As Boolean
If F = "" Then
File_Exists = False
Else
... |
http://rosettacode.org/wiki/Character_codes | Character codes |
Task
Given a character value in your language, print its code (could be ASCII code, Unicode code, or whatever your language uses).
Example
The character 'a' (lowercase letter A) has a code of 97 in ASCII (as well as Unicode, as ASCII forms the beginning of Unicode).
Conversely, given a code, print out... | #Racket | Racket | #lang racket
(define (code ch)
(printf "The unicode number for ~s is ~a\n" ch (char->integer ch)))
(code #\a)
(code #\λ)
(define (char n)
(printf "The unicode number ~a is the character ~s\n" n (integer->char n)))
(char 97)
(char 955) |
http://rosettacode.org/wiki/Character_codes | Character codes |
Task
Given a character value in your language, print its code (could be ASCII code, Unicode code, or whatever your language uses).
Example
The character 'a' (lowercase letter A) has a code of 97 in ASCII (as well as Unicode, as ASCII forms the beginning of Unicode).
Conversely, given a code, print out... | #Raku | Raku | for 'AΑА𪚥🇺🇸👨👩👧👦'.comb {
.put for
[ 'Character',
'Character name',
'Unicode property',
'Unicode script',
'Unicode block',
'Ordinal(s)',
'Hex ordinal(s)',
'UTF-8',
'UTF-16LE',
'UTF-16BE',
'Round trip by name',
'Round trip by ordinal'
... |
http://rosettacode.org/wiki/Check_that_file_exists | Check that file exists | Task
Verify that a file called input.txt and a directory called docs exist.
This should be done twice:
once for the current working directory, and
once for a file and a directory in the filesystem root.
Optional criteria (May 2015): verify it works with:
zero-length files
an ... | #VBScript | VBScript | Set FSO = CreateObject("Scripting.FileSystemObject")
Function FileExists(strFile)
If FSO.FileExists(strFile) Then
FileExists = True
Else
FileExists = False
End If
End Function
Function FolderExists(strFolder)
If FSO.FolderExists(strFolder) Then
FolderExists = True
Else
... |
http://rosettacode.org/wiki/Check_that_file_exists | Check that file exists | Task
Verify that a file called input.txt and a directory called docs exist.
This should be done twice:
once for the current working directory, and
once for a file and a directory in the filesystem root.
Optional criteria (May 2015): verify it works with:
zero-length files
an ... | #Vedit_macro_language | Vedit macro language | // In current directory
if (File_Exist("input.txt")) { M("input.txt exists\n") } else { M("input.txt does not exist\n") }
if (File_Exist("docs/nul", NOERR)) { M("docs exists\n") } else { M("docs does not exist\n") }
// In the root directory
if (File_Exist("/input.txt")) { M("/input.txt exists\n") } else { M("/input.t... |
http://rosettacode.org/wiki/Character_codes | Character codes |
Task
Given a character value in your language, print its code (could be ASCII code, Unicode code, or whatever your language uses).
Example
The character 'a' (lowercase letter A) has a code of 97 in ASCII (as well as Unicode, as ASCII forms the beginning of Unicode).
Conversely, given a code, print out... | #RapidQ | RapidQ |
Print Chr$(97)
Print Asc("a")
|
http://rosettacode.org/wiki/Character_codes | Character codes |
Task
Given a character value in your language, print its code (could be ASCII code, Unicode code, or whatever your language uses).
Example
The character 'a' (lowercase letter A) has a code of 97 in ASCII (as well as Unicode, as ASCII forms the beginning of Unicode).
Conversely, given a code, print out... | #Red | Red | Red []
print to-integer first "a" ;; -> 97
print to-integer #"a" ;; -> 97
print to-binary "a" ;; -> #{61}
print to-char 97 ;; -> a
|
http://rosettacode.org/wiki/Check_that_file_exists | Check that file exists | Task
Verify that a file called input.txt and a directory called docs exist.
This should be done twice:
once for the current working directory, and
once for a file and a directory in the filesystem root.
Optional criteria (May 2015): verify it works with:
zero-length files
an ... | #Visual_Basic | Visual Basic |
'declarations:
Public Declare Function GetFileAttributes Lib "kernel32" _
Alias "GetFileAttributesA" (ByVal lpFileName As String) As Long
Public Const INVALID_FILE_ATTRIBUTES As Long = -1
Public Const ERROR_SHARING_VIOLATION As Long = 32&
'implementation:
Public Function FileExists(ByVal Filename As String) As Bo... |
http://rosettacode.org/wiki/Character_codes | Character codes |
Task
Given a character value in your language, print its code (could be ASCII code, Unicode code, or whatever your language uses).
Example
The character 'a' (lowercase letter A) has a code of 97 in ASCII (as well as Unicode, as ASCII forms the beginning of Unicode).
Conversely, given a code, print out... | #Retro | Retro | 'c putc |
http://rosettacode.org/wiki/Character_codes | Character codes |
Task
Given a character value in your language, print its code (could be ASCII code, Unicode code, or whatever your language uses).
Example
The character 'a' (lowercase letter A) has a code of 97 in ASCII (as well as Unicode, as ASCII forms the beginning of Unicode).
Conversely, given a code, print out... | #REXX | REXX | /*REXX program displays a char's ASCII code/value (or EBCDIC if run on an EBCDIC system)*/
yyy= 'c' /*assign a lowercase c to YYY. */
yyy= "c" /* (same as above) */
say 'from char, yyy code=' yyy
yyy= '63'x ... |
http://rosettacode.org/wiki/Check_that_file_exists | Check that file exists | Task
Verify that a file called input.txt and a directory called docs exist.
This should be done twice:
once for the current working directory, and
once for a file and a directory in the filesystem root.
Optional criteria (May 2015): verify it works with:
zero-length files
an ... | #Visual_Basic_.NET | Visual Basic .NET | 'Current Directory
Console.WriteLine(If(IO.Directory.Exists("docs"), "directory exists", "directory doesn't exists"))
Console.WriteLine(If(IO.Directory.Exists("output.txt"), "file exists", "file doesn't exists"))
'Root
Console.WriteLine(If(IO.Directory.Exists("\docs"), "directory exists", "directory doesn't exists"))... |
http://rosettacode.org/wiki/Character_codes | Character codes |
Task
Given a character value in your language, print its code (could be ASCII code, Unicode code, or whatever your language uses).
Example
The character 'a' (lowercase letter A) has a code of 97 in ASCII (as well as Unicode, as ASCII forms the beginning of Unicode).
Conversely, given a code, print out... | #Ring | Ring |
see ascii("a") + nl
see char(97) + nl
|
http://rosettacode.org/wiki/Character_codes | Character codes |
Task
Given a character value in your language, print its code (could be ASCII code, Unicode code, or whatever your language uses).
Example
The character 'a' (lowercase letter A) has a code of 97 in ASCII (as well as Unicode, as ASCII forms the beginning of Unicode).
Conversely, given a code, print out... | #Ruby | Ruby | > "a".ord
=> 97
> 97.chr
=> "a" |
http://rosettacode.org/wiki/Check_that_file_exists | Check that file exists | Task
Verify that a file called input.txt and a directory called docs exist.
This should be done twice:
once for the current working directory, and
once for a file and a directory in the filesystem root.
Optional criteria (May 2015): verify it works with:
zero-length files
an ... | #Vlang | Vlang | // Check file exists in V
// Tectonics: v run check-that-file-exists.v
module main
import os
// starts here
pub fn main() {
// file and directory checks
_ := os.execute("touch input.txt")
println("os.is_file('input.txt'): ${os.is_file('input.txt')}")
// make doc directory in current dir if it doesn'... |
http://rosettacode.org/wiki/Check_that_file_exists | Check that file exists | Task
Verify that a file called input.txt and a directory called docs exist.
This should be done twice:
once for the current working directory, and
once for a file and a directory in the filesystem root.
Optional criteria (May 2015): verify it works with:
zero-length files
an ... | #Wren | Wren | import "io" for Directory, File
for (name in ["input.txt", "`Abdu'l-Bahá.txt"]) {
if (File.exists(name)) {
System.print("%(name) file exists and has a size of %(File.size(name)) bytes.")
} else {
System.print("%(name) file does not exist.")
}
}
var dir = "docs"
// if it exists get number... |
http://rosettacode.org/wiki/Character_codes | Character codes |
Task
Given a character value in your language, print its code (could be ASCII code, Unicode code, or whatever your language uses).
Example
The character 'a' (lowercase letter A) has a code of 97 in ASCII (as well as Unicode, as ASCII forms the beginning of Unicode).
Conversely, given a code, print out... | #Run_BASIC | Run BASIC | print chr$(97) 'prints a
print asc("a") 'prints 97 |
http://rosettacode.org/wiki/Character_codes | Character codes |
Task
Given a character value in your language, print its code (could be ASCII code, Unicode code, or whatever your language uses).
Example
The character 'a' (lowercase letter A) has a code of 97 in ASCII (as well as Unicode, as ASCII forms the beginning of Unicode).
Conversely, given a code, print out... | #Rust | Rust | use std::char::from_u32;
fn main() {
//ascii char
println!("{}", 'a' as u8);
println!("{}", 97 as char);
//unicode char
println!("{}", 'π' as u32);
println!("{}", from_u32(960).unwrap());
} |
http://rosettacode.org/wiki/Check_that_file_exists | Check that file exists | Task
Verify that a file called input.txt and a directory called docs exist.
This should be done twice:
once for the current working directory, and
once for a file and a directory in the filesystem root.
Optional criteria (May 2015): verify it works with:
zero-length files
an ... | #XPL0 | XPL0 |
int FD; \file descriptor
[Trap(false); \prevent errors from aborting program
FD:= FOpen("input.txt", 0);
if GetErr then Text(0, "input.txt doesn't exist^m^j");
FD:= FOpen("dir", 0);
if GetErr then Text(0, "dir doesn't exist^m^j");
FD:= FOpen("/input.txt", 0);
if GetErr then Text(0, "/input.txt doesn't exist^m... |
http://rosettacode.org/wiki/Check_that_file_exists | Check that file exists | Task
Verify that a file called input.txt and a directory called docs exist.
This should be done twice:
once for the current working directory, and
once for a file and a directory in the filesystem root.
Optional criteria (May 2015): verify it works with:
zero-length files
an ... | #Yabasic | Yabasic | open "foo.bar" for writing as #1
print #1 "Hallo !"
close #1
if (not open(1,"foo.bar")) print "Could not open 'foo.bar' for reading"
close #1
if (not open(1,"buzz.bar")) print "Could not open 'buzz.bar' for reading"
|
http://rosettacode.org/wiki/Character_codes | Character codes |
Task
Given a character value in your language, print its code (could be ASCII code, Unicode code, or whatever your language uses).
Example
The character 'a' (lowercase letter A) has a code of 97 in ASCII (as well as Unicode, as ASCII forms the beginning of Unicode).
Conversely, given a code, print out... | #Sather | Sather | class MAIN is
main is
#OUT + 'a'.int + "\n"; -- or
#OUT + 'a'.ascii_int + "\n";
#OUT + CHAR::from_ascii_int(97) + "\n";
end;
end; |
http://rosettacode.org/wiki/Character_codes | Character codes |
Task
Given a character value in your language, print its code (could be ASCII code, Unicode code, or whatever your language uses).
Example
The character 'a' (lowercase letter A) has a code of 97 in ASCII (as well as Unicode, as ASCII forms the beginning of Unicode).
Conversely, given a code, print out... | #Scala | Scala | scala> 'a' toInt
res2: Int = 97
scala> 97 toChar
res3: Char = a
scala> '\u0061'
res4: Char = a
scala> "\uD869\uDEA5"
res5: String = 𪚥 |
http://rosettacode.org/wiki/Check_that_file_exists | Check that file exists | Task
Verify that a file called input.txt and a directory called docs exist.
This should be done twice:
once for the current working directory, and
once for a file and a directory in the filesystem root.
Optional criteria (May 2015): verify it works with:
zero-length files
an ... | #zkl | zkl | File.exists("input.txt") //--> True (in this case a sym link)
File.exists("/input.txt") //-->False
File.isDir("/") //-->True
File.isDir("docs") //-->False
|
http://rosettacode.org/wiki/Character_codes | Character codes |
Task
Given a character value in your language, print its code (could be ASCII code, Unicode code, or whatever your language uses).
Example
The character 'a' (lowercase letter A) has a code of 97 in ASCII (as well as Unicode, as ASCII forms the beginning of Unicode).
Conversely, given a code, print out... | #Scheme | Scheme | (display (char->integer #\a)) (newline) ; prints "97"
(display (integer->char 97)) (newline) ; prints "a" |
http://rosettacode.org/wiki/Character_codes | Character codes |
Task
Given a character value in your language, print its code (could be ASCII code, Unicode code, or whatever your language uses).
Example
The character 'a' (lowercase letter A) has a code of 97 in ASCII (as well as Unicode, as ASCII forms the beginning of Unicode).
Conversely, given a code, print out... | #Seed7 | Seed7 | writeln(ord('a'));
writeln(chr(97)); |
http://rosettacode.org/wiki/Character_codes | Character codes |
Task
Given a character value in your language, print its code (could be ASCII code, Unicode code, or whatever your language uses).
Example
The character 'a' (lowercase letter A) has a code of 97 in ASCII (as well as Unicode, as ASCII forms the beginning of Unicode).
Conversely, given a code, print out... | #SenseTalk | SenseTalk | put CharToNum("a")
put NumToChar(97) |
http://rosettacode.org/wiki/Character_codes | Character codes |
Task
Given a character value in your language, print its code (could be ASCII code, Unicode code, or whatever your language uses).
Example
The character 'a' (lowercase letter A) has a code of 97 in ASCII (as well as Unicode, as ASCII forms the beginning of Unicode).
Conversely, given a code, print out... | #SequenceL | SequenceL | cmd:>asciiToInt('a')
97
cmd:>intToAscii(97)
'a' |
http://rosettacode.org/wiki/Character_codes | Character codes |
Task
Given a character value in your language, print its code (could be ASCII code, Unicode code, or whatever your language uses).
Example
The character 'a' (lowercase letter A) has a code of 97 in ASCII (as well as Unicode, as ASCII forms the beginning of Unicode).
Conversely, given a code, print out... | #Sidef | Sidef | say 'a'.ord; # => 97
say 97.chr; # => 'a' |
http://rosettacode.org/wiki/Character_codes | Character codes |
Task
Given a character value in your language, print its code (could be ASCII code, Unicode code, or whatever your language uses).
Example
The character 'a' (lowercase letter A) has a code of 97 in ASCII (as well as Unicode, as ASCII forms the beginning of Unicode).
Conversely, given a code, print out... | #Slate | Slate | $a code.
97 as: String Character. |
http://rosettacode.org/wiki/Character_codes | Character codes |
Task
Given a character value in your language, print its code (could be ASCII code, Unicode code, or whatever your language uses).
Example
The character 'a' (lowercase letter A) has a code of 97 in ASCII (as well as Unicode, as ASCII forms the beginning of Unicode).
Conversely, given a code, print out... | #Smalltalk | Smalltalk | ($a asInteger) displayNl. "output 97"
(Character value: 97) displayNl. "output a" |
http://rosettacode.org/wiki/Character_codes | Character codes |
Task
Given a character value in your language, print its code (could be ASCII code, Unicode code, or whatever your language uses).
Example
The character 'a' (lowercase letter A) has a code of 97 in ASCII (as well as Unicode, as ASCII forms the beginning of Unicode).
Conversely, given a code, print out... | #SmileBASIC | SmileBASIC | PRINT CHR$(97) 'a
PRINT ASC("a") '97 |
http://rosettacode.org/wiki/Character_codes | Character codes |
Task
Given a character value in your language, print its code (could be ASCII code, Unicode code, or whatever your language uses).
Example
The character 'a' (lowercase letter A) has a code of 97 in ASCII (as well as Unicode, as ASCII forms the beginning of Unicode).
Conversely, given a code, print out... | #SNOBOL4 | SNOBOL4 | define('chr(n)') :(chr_end)
chr &alphabet tab(n) len(1) . chr :s(return)f(freturn)
chr_end
define('asc(str)c') :(asc_end)
asc str len(1) . c
&alphabet break(c) @asc :s(return)f(freturn)
asc_end
* # Test and display
output = char(65) ;* Built-in
output = chr(65)
... |
Subsets and Splits
Rosetta Code COBOL Python Hard Tasks
Identifies and retrieves challenging tasks that exist in both COBOL and Python, revealing cross-language programming patterns and difficulty levels for comparative analysis.
Rosetta Code Task Comparisons
Identifies tasks common to both COBOL and Python languages that are described as having difficulty levels, revealing cross-language task similarities and providing useful comparative programming examples.
Select Specific Languages Codes
Retrieves specific programming language names and codes from training data, providing basic filtering but limited analytical value beyond identifying these particular languages.