Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
24
Task/Nested-function/Ada/nested-function.adb
Normal file
24
Task/Nested-function/Ada/nested-function.adb
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
with Ada.Text_IO;
|
||||
|
||||
procedure Nested_Functions is -- 'Nested_Functions' is the name of 'main'
|
||||
|
||||
type List is array(Natural range <>) of String(1 .. 10);
|
||||
|
||||
function Make_List(Separator: String) return List is
|
||||
Counter: Natural := 0;
|
||||
|
||||
function Make_Item(Item_Name: String) return String is
|
||||
begin
|
||||
Counter := Counter + 1; -- local in Make_List, global in Make_Item
|
||||
return(Natural'Image(Counter) & Separator & Item_Name);
|
||||
end Make_Item;
|
||||
|
||||
begin
|
||||
return (Make_Item("First "), Make_Item("Second"), Make_Item("Third "));
|
||||
end Make_List;
|
||||
|
||||
begin -- iterate through the result of Make_List
|
||||
for Item of Make_List(". ") loop
|
||||
Ada.Text_IO.Put_Line(Item);
|
||||
end loop;
|
||||
end Nested_Functions;
|
||||
9
Task/Nested-function/ArkScript/nested-function.ark
Normal file
9
Task/Nested-function/ArkScript/nested-function.ark
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
(let makeList (fun (separator) {
|
||||
(mut counter 1)
|
||||
(let makeItem (fun (item) {
|
||||
(let res (format "{}{}{}\n" counter separator item))
|
||||
(set counter (+ 1 counter))
|
||||
res }))
|
||||
(+ (makeItem "first") (makeItem "second") (makeItem "third")) }))
|
||||
|
||||
(print (makeList ". "))
|
||||
10
Task/Nested-function/Crystal/nested-function.cr
Normal file
10
Task/Nested-function/Crystal/nested-function.cr
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
def make_list (separator)
|
||||
counter = 1
|
||||
make_item = ->(text : String) {
|
||||
counter += 1
|
||||
"#{counter-1}#{separator}#{text}"
|
||||
}
|
||||
make_item["first"] + "\n" + make_item["second"] + "\n" + make_item["third"]
|
||||
end
|
||||
|
||||
puts make_list ". "
|
||||
21
Task/Nested-function/EasyLang/nested-function.easy
Normal file
21
Task/Nested-function/EasyLang/nested-function.easy
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
# The nested functions are subroutines
|
||||
# These don't have parameters or return values
|
||||
#
|
||||
func$ makelist sep$ .
|
||||
counter = 1
|
||||
subr makeitem
|
||||
item$ = counter & sep$ & txt$ & "\n"
|
||||
counter += 1
|
||||
.
|
||||
txt$ = "first"
|
||||
makeitem
|
||||
r$ &= item$
|
||||
txt$ = "second"
|
||||
makeitem
|
||||
r$ &= item$
|
||||
txt$ = "third"
|
||||
makeitem
|
||||
r$ &= item$
|
||||
return r$
|
||||
.
|
||||
print makelist ". "
|
||||
9
Task/Nested-function/Janet/nested-function.janet
Normal file
9
Task/Nested-function/Janet/nested-function.janet
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
(defn make-list [separator]
|
||||
(var i 0)
|
||||
(defn make-item [item]
|
||||
(printf "%d%s%s" (++ i) separator item))
|
||||
(make-item "first")
|
||||
(make-item "second")
|
||||
(make-item "third"))
|
||||
|
||||
(make-list ". ")
|
||||
16
Task/Nested-function/LOLCODE/nested-function.lol
Normal file
16
Task/Nested-function/LOLCODE/nested-function.lol
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
HAI 1.3
|
||||
|
||||
HOW IZ I MAKELIST YR SEP
|
||||
I HAS A COUNTER ITZ 1
|
||||
HOW IZ I MAKEITEM YR ITEM
|
||||
VISIBLE COUNTER SEP ITEM
|
||||
COUNTER R SUM OF COUNTER AN 1
|
||||
IF U SAY SO
|
||||
I IZ MAKEITEM YR "first" MKAY
|
||||
I IZ MAKEITEM YR "second" MKAY
|
||||
I IZ MAKEITEM YR "third" MKAY
|
||||
IF U SAY SO
|
||||
|
||||
I IZ MAKELIST YR ". " MKAY
|
||||
|
||||
KTHXBYE
|
||||
11
Task/Nested-function/Maxima/nested-function.maxima
Normal file
11
Task/Nested-function/Maxima/nested-function.maxima
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
make_list_rc(sep) := block(
|
||||
counter: 1,
|
||||
make_item(item) := block(
|
||||
out: sconcat(counter, sep, item),
|
||||
counter: counter+1,
|
||||
print(out)
|
||||
),
|
||||
map(make_item, ["first", "second", "third"])
|
||||
)$
|
||||
|
||||
make_list_rc(". ")$
|
||||
14
Task/Nested-function/Pluto/nested-function.pluto
Normal file
14
Task/Nested-function/Pluto/nested-function.pluto
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
local function make_list(sep)
|
||||
local counter = 0
|
||||
local function make_item(name)
|
||||
counter += 1
|
||||
return $"{counter}{sep}{name}"
|
||||
end
|
||||
local items = {}
|
||||
for {"first", "second", "third"} as name do
|
||||
items:insert(make_item(name))
|
||||
end
|
||||
print(items:concat("\n"))
|
||||
end
|
||||
|
||||
make_list(". ")
|
||||
Loading…
Add table
Add a link
Reference in a new issue