Stream: nix

Topic: ✔ Accessing list items in Nix


view this post on Zulip Andreas (Jun 14 2024 at 13:45):

alright, so I might just map over the list then and get all the items (in my case it's a list of attribue sets and I need the attributes)?

view this post on Zulip Andreas (Jun 14 2024 at 13:46):

it's just that i know in advance how many items there are going to be, so I didn't think of mapping immediately

view this post on Zulip Andreas (Jun 14 2024 at 13:48):

okay so there is lib.lists.imap0 and lib.lists.imap1 and builtins.map... usually I'd just grab the last, but is there a major difference?

view this post on Zulip Tim DeHerrera (Jun 14 2024 at 13:51):

Well what's the specific problem? Maybe I can give you a more specific example.

imap0 iterates a list with an additional index starting at 0, imap1 is same but starting at 1.

If you don't need an index to keep track of them map is fine, as is always in scope so you can just type map instead of builtins.map

view this post on Zulip Andreas (Jun 14 2024 at 13:52):

I do think that answers the problem :smile:

view this post on Zulip Notification Bot (Jun 14 2024 at 13:52):

Andreas has marked this topic as resolved.


Last updated: Nov 15 2024 at 13:04 UTC