# What is a 'λ-Scoped(x, scope={})'

**URL:** <https://community.riskscape.org.nz/t/what-is-a-scoped-x-scope/193>\
**Category:** Community\
**Created:** [2 October 2024 01:30 UTC](https://community.riskscape.org.nz/t/what-is-a-scoped-x-scope/193 "2024-10-02T01:30:23Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![timbeale](https://avatars.discourse-cdn.com/v4/letter/t/57b2e6/32.png) [@timbeale](https://community.riskscape.org.nz/u/timbeale)\
**Post date:** [2 October 2024 02:09 UTC](https://community.riskscape.org.nz/t/what-is-a-scoped-x-scope/193/2 "2024-10-02T02:09:40Z")

</div>

Kia ora,

That’s a scoped lambda type. There’s an explanation in the docs about what RiskScape lambda expressions are here:  
[https://riskscape.org.nz/docs/intermediate/write-expressions.html#lambda-expressions](https://riskscape.org.nz/docs/intermediate/write-expressions.html#lambda-expressions)

The ‘scoped’ part just means the lambda expression can access any other attributes that are accessible for that particular pipeline step (e.g. exposure attributes).

The `create_continuous()` function expects a lambda expression that will yield a `y` value for a given `x` value. (Replace x and y with domain-appropriate modelling terminology, e.g. x=flood depth, y=DR). For example, a simple example of a lambda expression might be: `x -> if(x > 500, then: 0.2, else: 0.1)`.

This is not exactly what you want here. What you want is more like ‘given a predetermined x value, return a predetermined y value’. The simplest way to do this in a pipeline is via a ‘lookup table’. Here’s an example:

```auto
input(value: { x_point: [0.0,500.0,1000.0], y_point: [0.0,0.1,0.2] })
->
unnest([x_point, y_point]) as foo
->
group({ to_lookup_table(key: x_point, value: y_point, options: { unique: true }) as lookup_table })
->
select({
	create_continuous(
	[0.0,500.0,1000.0],
	x -> lookup(lookup_table, x)) as testCurve
})
->
select({
        apply_continuous(testCurve, 250) as y250,
        apply_continuous(testCurve, 750) as y750
})

```

Hope that helps.

Tim

---

_[View the full topic](https://community.riskscape.org.nz/t/what-is-a-scoped-x-scope/193)._
