WolframLang: Position of an Element

By Xah Lee. Date: . Last updated: .

Position Spec

A position is a list of integers that uniquely specify a part of expression.

For example, if we have

{a, {{b,c}, d}, e}

Index counting start at 1. Index 0 means the Head of Expression.

Get Element by Position Spec: Extract

Extract[expr, position]
return the part of expr at a given position. Extract
tree = {a, {{b,c}, d}, e};

Extract[ tree, {1} ] === a

Extract[ tree, {2} ] === {{b, c}, d}

Extract[ tree, {3} ] === e

Extract[ tree, {2, 1} ] === {b, c}

Extract[ tree, {2, 1, 1} ] === b

List

WolframLang in Depth

Basics

Comment, Print

String

Arithmetic

List

Expression, Atom, Head

Boolean

Conditional

Variable

Loop

Data Structure

Function

Pattern Matching

Advanced

Shell Tasks

Misc