Skip to content

Commit 2a240d0

Browse files
Kotlin functions, Python 3 IO (as remnants of other tasks)
1 parent 056d652 commit 2a240d0

File tree

2 files changed

+147
-0
lines changed

2 files changed

+147
-0
lines changed
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
{
2+
"meta": {
3+
"language": "kotlin",
4+
"language_name": "Kotlin",
5+
"structure": "functions",
6+
"language_version": "1.5"
7+
},
8+
"concepts": {
9+
"void_function_no_parameters": {
10+
"code": "fun functionName() {\n // statements\n}",
11+
"name": "Function that does not return a value and takes no parameters"
12+
},
13+
"void_function_with_parameters": {
14+
"code": "fun functionName(param1: Type, param2: Type) {\n // statements\n}",
15+
"name": "Function that does not return a value and that takes 1 or more defined parameters"
16+
},
17+
"void_function_with_optional_parameters": {
18+
"code": "fun functionName(param1: Type, param2: Type = defaultValue) {\n // statements\n}",
19+
"name": "Function that does not return a value and that takes 1 or more optional parameters (with default values)"
20+
},
21+
"void_function_variable_parameters": {
22+
"code": "fun functionName(vararg params: Type) {\n // statements\n}",
23+
"name": "Function that does not return a value and function that takes an unknown number of parameters"
24+
},
25+
"return_value_function_no_parameters": {
26+
"code": "fun functionName(): ReturnType {\n // statements\n return expression\n}",
27+
"name": "Function that returns a value and takes no parameters"
28+
},
29+
"return_value_function_with_parameters": {
30+
"code": "fun functionName(param1: Type, param2: Type): ReturnType {\n // statements\n return expression\n}",
31+
"name": "Function that returns a value and takes 1 or more defined parameters"
32+
},
33+
"return_value_function_with_optional_parameters": {
34+
"code": "fun functionName(param1: Type, param2: Type = defaultValue): ReturnType {\n // statements\n return expression\n}",
35+
"name": "Function that returns a value and takes 1 or more optional parameters (with default values)"
36+
},
37+
"return_value_function_variable_parameters": {
38+
"code": "fun functionName(vararg params: Type): ReturnType {\n // statements\n return expression\n}",
39+
"name": "Function that returns a value and takes an unknown number of parameters"
40+
},
41+
"anonymous_function_no_parameters": {
42+
"code": "{ -> // statements }",
43+
"name": "Anonymous function that takes no parameters"
44+
},
45+
"anonymous_function_with_parameters": {
46+
"code": "{ param1: Type, param2: Type -> // statements }",
47+
"name": "Anonymous function that takes 1 or more defined parameters"
48+
},
49+
"anonymous_function_variable_parameters": {
50+
"not-implemented": true,
51+
"name": "Anonymous function that takes an unknown number of parameters"
52+
},
53+
"anonymous_function_no_parameters_with_return": {
54+
"code": "{ -> expression }",
55+
"name": "Anonymous function that takes no parameters and returns a value"
56+
},
57+
"anonymous_function_with_parameters_with_return": {
58+
"code": "{ param1: Type, param2: Type -> expression }",
59+
"name": "Anonymous function that takes 1 or more defined parameters and returns a value"
60+
},
61+
"extension_function": {
62+
"code": "fun ReceiverType.functionName() {\n // statements\n}",
63+
"comment": "Extension functions allow you to add new functions to existing classes without inheriting from them.",
64+
"name": "Extension functions"
65+
},
66+
"named_arguments": {
67+
"code": "functionName(param2 = value2, param1 = value1)",
68+
"name": "Named arguments in function calls"
69+
},
70+
"async_function": {
71+
"code": "suspend fun functionName() {\n // statements\n}",
72+
"name": "Asynchronous function (async/await)"
73+
}
74+
}
75+
}

web/thesauruses/python/3/io.json

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
{
2+
"meta": {
3+
"language": "python",
4+
"language_version": "3",
5+
"language_name": "Python",
6+
"structure": "io"
7+
},
8+
"concepts": {
9+
"write_line": {
10+
"code": "print(content, end='')"
11+
},
12+
"write_line_with_new_line": {
13+
"code": "print(content)"
14+
},
15+
"read_line": {
16+
"code": "variable = input(prompt)"
17+
},
18+
"clear_console_output": {
19+
"code": [
20+
"import os",
21+
"os.system('cls' if os.name == 'nt' else 'clear')"
22+
]
23+
},
24+
"file_functions_lib": {
25+
"code": "import os"
26+
},
27+
"list_directory": {
28+
"code": "os.listdir(path)"
29+
},
30+
"create_directory": {
31+
"code": "os.mkdir(path)"
32+
},
33+
"delete_directory": {
34+
"code": "os.rmdir(path)"
35+
},
36+
"check_file_exists": {
37+
"code": "os.path.isfile(path)"
38+
},
39+
"check_directory_exists": {
40+
"code": "os.path.isdir(path)"
41+
},
42+
"get_file_size": {
43+
"code": "os.path.getsize(path)"
44+
},
45+
"get_file_last_modified": {
46+
"code": "os.path.getmtime(path)"
47+
},
48+
"get_environment_variable": {
49+
"code": "os.environ.get('VARIABLE_NAME')"
50+
},
51+
"set_environment_variable": {
52+
"code": "os.environ['VARIABLE_NAME'] = 'value'"
53+
},
54+
"list_all_environment_variables": {
55+
"code": "os.environ"
56+
},
57+
"create_temporary_file": {
58+
"code": [
59+
"import tempfile",
60+
"with tempfile.NamedTemporaryFile(delete=False) as fp:",
61+
" fp.write(content)"
62+
]
63+
},
64+
"create_temporary_directory": {
65+
"code": [
66+
"import tempfile",
67+
"with tempfile.TemporaryDirectory() as tmpdirname:",
68+
" print('created temporary directory', tmpdirname)"
69+
]
70+
}
71+
}
72+
}

0 commit comments

Comments
 (0)