REBOL Document

Select - Function Summary


Summary:

Finds a value in the series and returns the value or series after it.

Usage:

select series value

Arguments:

series - The series argument. (must be: series port)

value - The value argument. (must be: any-type)

Refinements:

/part - Limits the search to a given length or position.

range - The range argument. (must be: number series port)

/only - Treats a series value as a single value.

/case - Characters are case-sensitive.

/any - Enables the * and ? wildcards.

/with - Allows custom wildcards.

wild - Specifies alternates for * and ? (must be: string)

/skip - Treat the series as records of fixed size

size - The size argument. (must be: integer)

Description:

Similar to the FINDfunction, but returns the next value in the series rather than the position of the match. Returns NONE if search failed.

The /ONLY refinement is evaluated for a block argument and is ignored if the argument is a string.


    blk: [red 123 green 456 blue 789]
    print select blk 'red
    123


    weather: [
        "Ukiah"      [clear 78 wind from NW at 5 MPH]
        "Santa Rosa" [overcast 65 wind from N at 10 MPH]
        "Eureka"     [rain 62 wind from N at 15 MPH]
    ]
    probe select weather "Eureka"
    [rain 62 wind from N at 15 MPH]

Related:

find - Finds a value in a series and returns the series at the start of it.
switch - Selects a choice and evaluates what follows it.


<Back | Index | Next>

Copyright 2004 REBOL Technologies