This commit is contained in:
NaiJi ✨ 2022-04-05 15:14:25 +03:00
commit 0d505a3d3c
10 changed files with 74 additions and 0 deletions

3
01.nix Normal file
View File

@ -0,0 +1,3 @@
{
helloWorld = "Hello" + " " + "World";
}

4
02.nix Normal file
View File

@ -0,0 +1,4 @@
# code goes here
{
v="understood";
}

8
03.nix Normal file
View File

@ -0,0 +1,8 @@
let
h = "Hello";
w = "World";
s = " ";
in
{
helloWorld = h + s + w;
}

6
04.nix Normal file
View File

@ -0,0 +1,6 @@
let
h = "Hello";
in
{
helloWorld = "${h} World"; # Modify this line
}

7
05.nix Normal file
View File

@ -0,0 +1,7 @@
let
h = "Strings";
value = 4;
in
{
helloWorld = "${h} ${toString value} the win!";
}

8
06.nix Normal file
View File

@ -0,0 +1,8 @@
let
f = "f";
o = "o";
func = a: b: c: a + b + c;
in
{
foo = func f o "o";
}

8
07.nix Normal file
View File

@ -0,0 +1,8 @@
let
f = "f";
o = "o";
func = {a, b, c}: a + b + c;
in
{
foo = func {a=f; b=o; c="o";};
}

8
08.nix Normal file
View File

@ -0,0 +1,8 @@
let
min = a: b: if (a > b) then b else a; #modify these
max = a: b: if (a > b) then a else b; #two lines only
in
{
ex0 = min 5 3;
ex1 = max 9 4;
}

11
09.nix Normal file
View File

@ -0,0 +1,11 @@
let
f = "f";
o = "o";
b = "b";
func = {a ? f, b ? "a", c ? ""}: a+b+c; #only modify this line!
in
rec {
foo = func {b="o"; c=o;}; #must evaluate to "foo"
bar = func {a=b; c="r";}; #must evaluate to "bar"
foobar = func {a=foo;b=bar;}; #must evaluate to "foobar"
}

11
10.nix Normal file
View File

@ -0,0 +1,11 @@
let
arguments = {a="f"; b="o"; c="o"; d="bar";}; #only modify this line
func = {a, b, c, ...}: a+b+c;
func2 = args@{a, b, c, ...}: a+b+c+args.d;
in
{
#the argument d is not used
foo = func arguments;
#now the argument d is used
foobar = func2 arguments;
}