Instructions
- class Let(*args)[source]
Use cases of LetAlgoVision
Python
Description
Let('a', 'x')a = xVariable
ais set to the value of variablex.Let('a', lambda x: x**2)a = x**2As soon as we compute anything on the right hand side of the equation, we need to write it as a
lambdaexpression.Let('a', 'array', ['i'])a = array[i]Indexing on the right hand requires an additional list parameter after the second argument.
Let('a', lambda array, i: array[:, i])a = array[i]Equivalent to the row above: indexing can also be manually done inside of a
lambdaexpression. Note that in this case, the batch dimension has to be written explicitly.Let('a', 'array', ['i', lambda j: j+1])a = array[i, j+1]Multiple indices and lambda expressions are also supported.
Let('a', 'array', [None, slice(0, None, 2)])a = array[:, 0::2]Noneandslices are also supported.Let('a', ['i'], 'x')a[i] = xIndexing can also be done on the left hand side of the equation.
Let('a', ['i'], 'x', ['j'])a[i] = x['j']…or on both sides.
Let(['a', 'b'], lamba x, y: (x+y, x-y))a, b = x+y, x-yMultiple return values are supported.
- class LetInt(*args)[source]
- __init__(*args)[source]
The
LetIntmodule executes a lambda or arbitrary other function and writes the return values back to the specified integer variable. Valid values are integers, lists of integers, and lambda expressions returning either of the first two, or strings corresponding to variables.