JanetDocsI'm feeling luckyGithub sign in

next



    function

    (next ds &opt key)
    
    Gets the next key in a data structure. Can be used to iterate through
    the keys of a data structure in an unspecified order. Keys are
    guaranteed to be seen only once per iteration if they data structure is
    not mutated during iteration. If key is nil, next returns the first
    key. If next returns nil, there are no more keys to iterate through.


1 exampleSign in to add an example
Loading...
(next  [4 5 6]    )  # => 0
(next  [4 5 6]  0 )  # => 1
(next  [4 5 6]  1 )  # => 2
(next  [4 5 6]  2 )  # => nil

# note that dictionary keys are not necessarily in the same order
# as the corresponding literal.
(next  {:a 5 :b 6 :c 7}     )  # => :a
(next  {:a 5 :b 6 :c 7}  :a )  # => :c
(next  {:a 5 :b 6 :c 7}  :c )  # => :b
(next  {:a 5 :b 6 :c 7}  :b )  # => nil
cellularmitosis