{
  "category": "Logical functions",
  "display_name": "SCAN",
  "entry_kind": "built_in_function",
  "eval_api": {
    "method": "POST",
    "url": "https://handbook.dnacalc.com/api/eval"
  },
  "function_id": "FUNC.SCAN",
  "implementation_state": {
    "answer_bank": null,
    "detail": "Recorded: 21 workbook cells.",
    "dnacalc_commit": "9e1884369a678158dd82d3d74188daf986995e87",
    "in_catalogue": true,
    "state": "matches",
    "state_label": "Matches every recorded Excel answer",
    "summary": "Matches all 21 recorded answers",
    "workbook_corpus": {
      "cells": 21,
      "matched": 21
    }
  },
  "implementations": [
    {
      "commit": "9e1884369a678158dd82d3d74188daf986995e87",
      "flavour": "excel-compatibility-candidate",
      "language": "Rust",
      "name": "CalcFunc",
      "own_code": [
        "https://github.com/DnaCalc/DnaCalc/blob/9e1884369a678158dd82d3d74188daf986995e87/crates/calc-func/src/catalogue/lambda_helpers.rs#L451-L451",
        "https://github.com/DnaCalc/DnaCalc/blob/9e1884369a678158dd82d3d74188daf986995e87/crates/calc-func/src/catalogue/lambda_helpers.rs#L184-L190"
      ],
      "repository": "https://github.com/DnaCalc/DnaCalc",
      "shared_code": [
        "catalogue/lambda_helpers::prepared",
        "catalogue/lambda_helpers::lambda",
        "catalogue/lambda_helpers::item",
        "catalogue/lambda_helpers::cell",
        "catalogue/lambda_helpers::items",
        "catalogue/lambda_helpers::array",
        "catalogue/lambda_helpers::reduce_task",
        "catalogue/lambda_helpers::helper",
        "catalogue/lambda_helpers::HelperTask::advance",
        "catalogue/lambda_helpers::run"
      ],
      "source": "https://github.com/DnaCalc/DnaCalc/blob/9e1884369a678158dd82d3d74188daf986995e87/crates/calc-func/src/catalogue/lambda_helpers.rs#L451-L451",
      "state": "matches",
      "suite": null,
      "summary": "Matches all 21 recorded answers"
    }
  ],
  "json_url": "https://handbook.dnacalc.com/api/functions/FUNC.SCAN.json",
  "name": "SCAN",
  "notes": [],
  "schema": "efh.function-reference/v1",
  "section_order": [
    "what-it-does",
    "try-it",
    "quirks",
    "how-to-implement",
    "version-differences",
    "alternatives"
  ],
  "sections": {
    "alternatives": "\n[REDUCE](FUNC.REDUCE.md) returns just the final accumulator; [MAP](FUNC.MAP.md) transforms elements independently; [MAKEARRAY](FUNC.MAKEARRAY.md) builds from coordinates.\n\n\n",
    "how-to-implement": "\n1. Prepare the initial accumulator and input, reading references as their held values. Preserve input shape and value kinds.\n2. Validate a two-parameter callable. Traverse input cells in row order.\n3. At each cell, invoke the lambda with `(accumulator,current_value)`. Replace the accumulator with the returned value, then publish the admissible scalar or singleton cell at the corresponding output coordinate.\n4. Retain the updated accumulator for the next invocation. Do not restart it at a row boundary and do not include the initial value as a separate output.\n5. Return the array in the input shape. A yielding evaluator must preserve the accumulator and next position across suspension.\n\nThe current route for `SCAN(0,{1,2;3,4},LAMBDA(a,v,10*a+v))` produces first row `1,12`, then second row `123,1234`. This makes traversal order visible and shows that row two continues the state from row one. The result follows from the cited helper; it is not a fresh Excel capture.\n\n\n",
    "quirks": "\nThe lambda needs two parameters: the previous accumulator and the current value. The calculation is its body, not a third lambda parameter. An invalid callable or incorrect parameter count gives `#VALUE!`. Set the initial value to `\"\"` for text concatenation.\n\nThe current helper traverses rows from left to right, then advances to the next row. It returns the input’s shape. It admits a one-cell array result by publishing that cell, but an intermediate result with several cells gives `#CALC!`; SCAN cannot spill a separate subarray from every input position. REDUCE has a different publication rule and can retain an array as its final accumulator.\n\nEmpty cells and error values remain values passed to the callable. The body can decide how to handle them; reducing everything to a prefiltered numeric list would change the function.\n\n\n",
    "sources": "\n- [Microsoft: SCAN function](https://support.microsoft.com/en-us/office/scan-function-d58dfd11-9969-4439-b2dc-e7062724de29), opened 6 November 2026; syntax, documented argument rules and errors.\n- [DnaCalc row-order traversal, accumulator state and singleton publication](https://github.com/DnaCalc/DnaCalc/blob/da3ecc4fb19a3a5529708c311d0e8f05688ac165/crates/calc-func/src/catalogue/lambda_helpers.rs).\n\n",
    "try-it": "\n`=SCAN(0,{3,1,4},LAMBDA(a,v,a+v))` returns `{3,4,8}`. The initial zero starts the calculation but is not an extra output element.\n\nFor text, `=SCAN(\"\",{\"d\",\"n\",\"a\"},LAMBDA(a,v,a&v))` returns `{\"d\",\"dn\",\"dna\"}`. Each result contains the state after consuming the next letter. The accumulator need not be numeric.\n\n\n",
    "version-differences": "\nNo same-input comparison between named Excel builds is recorded for this function here. The documented behaviour below is not a measurement of every Excel release.\n\n\n",
    "what-it-does": "\n`SCAN([initial_value], array, LAMBDA(accumulator,value,calculation))` returns every intermediate value of a running calculation. Each invocation receives the previous accumulator and the next input.\n\n\n"
  },
  "signature": {
    "display": "SCAN(initial_value, array, lambda)",
    "parameters": [
      {
        "description": null,
        "name": "initial_value",
        "optional": false,
        "repeats": false
      },
      {
        "description": null,
        "name": "array",
        "optional": false,
        "repeats": false
      },
      {
        "description": null,
        "name": "lambda",
        "optional": false,
        "repeats": false
      }
    ],
    "trailing_repeats": false
  },
  "sources": {
    "metadata": {
      "admission": {
        "label": "implemented",
        "reason": null
      },
      "arity": {
        "max": 3,
        "min": 3
      },
      "category": "Logical functions",
      "classification": {
        "arg_preparation_profile": "ValuesOnlyPreAdapter",
        "coercion_lift_profile": "Custom",
        "determinism_class": "Deterministic",
        "error_collapse_profile": "ReductionFold",
        "fec_dependency_profile": "None",
        "host_interaction_class": "None",
        "kernel_signature_class": "Custom",
        "rich_value_usage": "RichBlind",
        "surface_fec_dependency_profile": "RefOnly",
        "thread_safety_class": "SafePure",
        "volatility_class": "NonVolatile"
      },
      "descriptions": {
        "long": null,
        "short": "Every intermediate value of a running calculation by a LAMBDA over an array",
        "short_source": "dna-calc-own"
      },
      "docs": {
        "english_description": "Scans an array by applying a LAMBDA to each value and returns an array that has each intermediate value",
        "microsoft_url": "https://support.microsoft.com/en-us/office/scan-function-d58dfd11-9969-4439-b2dc-e7062724de29"
      },
      "entry_kind": "built_in_function",
      "localized_family_names": null,
      "localized_names": [
        {
          "locale": "ar-SA",
          "name": "SCAN"
        },
        {
          "locale": "bg-BG",
          "name": "SCAN"
        },
        {
          "locale": "cs-CZ",
          "name": "SCAN"
        },
        {
          "locale": "da-DK",
          "name": "SCAN"
        },
        {
          "locale": "de-DE",
          "name": "SCAN"
        },
        {
          "locale": "el-GR",
          "name": "SCAN"
        },
        {
          "locale": "en-AU",
          "name": "SCAN"
        },
        {
          "locale": "en-GB",
          "name": "SCAN"
        },
        {
          "locale": "en-US",
          "name": "SCAN"
        },
        {
          "locale": "es-ES",
          "name": "SCAN"
        },
        {
          "locale": "et-EE",
          "name": "SCAN"
        },
        {
          "locale": "fi-FI",
          "name": "SCAN"
        },
        {
          "locale": "fr-FR",
          "name": "SCAN*"
        },
        {
          "locale": "he-IL",
          "name": "SCAN"
        },
        {
          "locale": "hr-HR",
          "name": "SCAN"
        },
        {
          "locale": "hu-HU",
          "name": "SCAN"
        },
        {
          "locale": "id-ID",
          "name": "SCAN"
        },
        {
          "locale": "it-IT",
          "name": "SCAN"
        },
        {
          "locale": "ja-JP",
          "name": "SCAN"
        },
        {
          "locale": "ko-KR",
          "name": "SCAN"
        },
        {
          "locale": "lt-LT",
          "name": "SCAN"
        },
        {
          "locale": "lv-LV",
          "name": "SCAN"
        },
        {
          "locale": "nb-NO",
          "name": "SCAN"
        },
        {
          "locale": "nl-NL",
          "name": "SCANNEN"
        },
        {
          "locale": "pl-PL",
          "name": "SCAN"
        },
        {
          "locale": "pt-BR",
          "name": "SCAN"
        },
        {
          "locale": "pt-PT",
          "name": "SCAN"
        },
        {
          "locale": "ro-RO",
          "name": "SCAN"
        },
        {
          "locale": "ru-RU",
          "name": "SCAN"
        },
        {
          "locale": "sk-SK",
          "name": "SCAN"
        },
        {
          "locale": "sl-SI",
          "name": "SCAN"
        },
        {
          "locale": "sr-Latn-RS",
          "name": "SKENIRANJE"
        },
        {
          "locale": "sv-SE",
          "name": "SCAN"
        },
        {
          "locale": "th-TH",
          "name": "SCAN"
        },
        {
          "locale": "tr-TR",
          "name": "SCAN"
        },
        {
          "locale": "uk-UA",
          "name": "SCAN"
        },
        {
          "locale": "vi-VN",
          "name": "SCAN"
        },
        {
          "locale": "zh-CN",
          "name": "SCAN"
        },
        {
          "locale": "zh-HK",
          "name": "SCAN"
        },
        {
          "locale": "zh-TW",
          "name": "SCAN"
        }
      ],
      "signature": {
        "display": "SCAN(initial_value, array, lambda)",
        "parameters": [
          {
            "description": null,
            "name": "initial_value",
            "optional": false,
            "repeats": false
          },
          {
            "description": null,
            "name": "array",
            "optional": false,
            "repeats": false
          },
          {
            "description": null,
            "name": "lambda",
            "optional": false,
            "repeats": false
          }
        ],
        "trailing_repeats": false
      },
      "surface_name": "SCAN",
      "version_marker": null,
      "xlcall": null
    },
    "microsoft": "https://support.microsoft.com/en-us/office/scan-function-d58dfd11-9969-4439-b2dc-e7062724de29"
  },
  "try_it": {
    "formula": "=SCAN(0,{3,1,4},LAMBDA(a,v,a+v))"
  },
  "url": "https://handbook.dnacalc.com/functions/SCAN.html",
  "variants": [],
  "versions": []
}