-
Notifications
You must be signed in to change notification settings - Fork 0
/
Language_List.php
40 lines (32 loc) · 1.01 KB
/
Language_List.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Instructions
// In this exercise you need to implement some functions to manipulate a list of programming languages.
// #1 - Define a function to return an empty language list
// #2 - Modify function to create a list from any number of languages
// #3 - Define a function to add a language to the list
// #4 - Define a function to remove an item from the language list
// #5 - Define a function to get the first item in the list
// #6 - Define a function to return how many languages are in the list
<?php
declare(strict_types=1);
function language_list(string ...$languages): array
{
return $languages;
}
function add_to_language_list(array $languages, string $newLanguage): array
{
$languages[] = $newLanguage;
return $languages;
}
function prune_language_list(array $languages): array
{
array_shift($languages);
return $languages;
}
function current_language(array $languages): string
{
return $languages[0];
}
function language_list_length(array $languages): int
{
return count($languages);
}