I’m working my way through an online Nix Language tutorial at NixCloud.io
Below is an example of Lesson 20 of 34
Examples #9, #10 and #11 (commented out) involve the take, drop and unique commands for Nix lists, but when I search the online Nix docs I can find nothing about the commands nor examples on how to use them. I’ve been able to correctly infer the operation of most the commands through trial and error, but these last three commands have eluded me.
Do online docs exist somewhere that describe these commands, or is the tutorial perhaps using a version of Nix where these commands have been deprecated?
with import <nixpkgs> { };
with stdenv.lib;
let
list = [2 "4" true true {a = 27;} 2];
f = x: isString x;
s = "foobar";
in
{
#replace all X, everything should evaluate to true
ex00 = isList list;
ex01 = elemAt list 2 == true;
ex02 = length list == 6;
ex03 = last list == 2;
ex04 = filter f list == [ "4" ];
ex05 = head list == 2;
ex06 = tail list == ["4" true true {a = 27;} 2];
ex07 = remove true list == [ 2 "4" {a = 27;} 2 ];
ex08 = toList s == [ "foobar" ];
#ex09 = take 3 list == [ XXX];
#ex10 = drop 4 list == [XXXX ];
#ex11 = unique list == [ XXX ];
ex12 = list ++ ["x" "y"] == [ 2 "4" true true {a = 27;} 2 "x" "y" ];
}