GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||
GeezerVison is showing reference.wolfram.com — Scan—Wolfram Documentation Details and Options
Examples
Basic Examples
Scope
Level Specifications
Generalizations & Extensions
Options
Heads
Applications
Properties & Relations
See Also
Tech Notes
Related Guides
History
Cite this Page
ScanDetails and Options
Examplesopen all close allBasic Examples (6)Scan[Print, {a, b, c}]Scan[Print[# ^ 2]&, {2, 3, 4}]Scan elements of an Association: Scan[Print, <|1 -> a, 2 -> b, 3 -> c|>]Scan elements up to the second level: Scan[Print, <|1 -> {{a}}, 2 -> b|>, 2]Scan elements including the 0 Scan[Print, <|1 -> {a}|>, {0, Infinity}]Use the operator form of Scan: Scan[Print][{a, b, c}]Scope (5)Level Specifications (5)Scan level 1 (default): Scan[Print, {{{{{a}}}}}]Scan down to level 2: Scan[Print, {{{{{a}}}}}, 2]Scan only level 2: Scan[Print, {{{{{a}}}}}, {2}]Scan levels 0 through 2: Scan[Print, {{{{{a}}}}}, {0, 2}]Scan down to level 3: Scan[Print, {{{{{a}}}}}, 3]Scan all levels, starting at level 1: Scan[Print, {{{a}}}, Infinity]Scan also level 0: Scan[Print, {{{a}}}, {0, Infinity}]Negative levels: Scan[Print, {{{{a}}}}, -1]Scan[Print, {{{{a}}}}, -2]Scan[Print, {{{{a}}}}, {-2}]Positive and negative levels can be mixed: Scan[Print, {{{{{a}}}}}, {2, -3}]Different heads at each level: Scan[Print, h0[h1[h2[h3[h4[a]]]]], {2, -3}]Generalizations & Extensions (2)Options (1)Heads (1)By default, heads are not scanned: Scan[Print, {a, b}]Scan[Print, {a, b}, Heads -> True]Applications (2)Make assignments based on data: Scan[(u[#] = x)&, {55, 11, 77, 88}]{u[76], u[77], u[78]}Find all leaves in an expression: Integrate[1 / (x ^ 3 - 1), x]Reap[Scan[Sow, %, {-1}]][[2, 1]]Properties & Relations (4)Leaves are visited before roots: Scan[Print, {a, {b, {c}}}, {0, -1}];Scan does the same as Map, but without returning a result: Map[Print, {a, b, c}]Scan[Print, {a, b, c}]Use Sow and Reap to collect results: Reap[Scan[If[# > 0, Sow[#]]&, {1, {-2, π}, -Sqrt[3]}, ∞]][[2, 1]]Compute Scan in parallel: Parallelize[Scan[Print, Range[5]]]Tech NotesRelated GuidesHistoryIntroduced in 1988 (1.0) | Updated in 1996 (3.0) ▪ 2003 (5.0) ▪ 2014 (10.0)
Wolfram Research (1988), Scan, Wolfram Language function, https://reference.wolfram.com/language/ref/Scan.html (updated 2014).
TextWolfram Research (1988), Scan, Wolfram Language function, https://reference.wolfram.com/language/ref/Scan.html (updated 2014). CMSWolfram Language. 1988. "Scan." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2014. https://reference.wolfram.com/language/ref/Scan.html. APAWolfram Language. (1988). Scan. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Scan.html BibTeX@misc{reference.wolfram_2026_scan, author="Wolfram Research", title="{Scan}", year="2014", howpublished="\url{https://reference.wolfram.com/language/ref/Scan.html}", note=[Accessed: 12-November-2026]} BibLaTeX@online{reference.wolfram_2026_scan, organization={Wolfram Research}, title={Scan}, year={2014}, url={https://reference.wolfram.com/language/ref/Scan.html}, note=[Accessed: 12-November-2026]} | ||||||||||||
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |