NEWTON
Asked
6 months ago
58
views
0
Just saw this in Cairo v0.10 docs: "support using functions as expressions" Can anyone explain how does that work exactly? any example would be very helpful It's mentioned here: https://github.com/starkware-libs/cairo-lang/releases/tag/v0.10.0#:~:text=Support%20using%20functions%20as%20expressions
This question was originally posted on StarkNet Discord
Newton
asked
6 months ago
0
Accepted answer
It means doing things like
let x = foo(y) + z;
let a = foo(bar(b));
etc.
Note that it currently only works for functions that return a felt (not a tuple) with a known ap change, which means no recursive functions, and no if statements (mostly. I think certain if-statements work but I haven't tried it myself)
I'm not sure that second line works. I thought the same, but I'm getting compile time errors thrown on structures like that expecting bar
to be a Struct rather than a function
the first definitely works
This answer was originally posted on StarkNet Discord
Newton
answered
6 months ago
Will it be possible to invoke functions from within the loops in Cairo 1.0?
Cairo: How can i approve erc20 and transfer in the same transaction?
Cairo: Getting the zero address
How to calculate the minimum decimal number that can store 20 chars long string as a field element?
Does Cairo work in python3.10 venv? I can’t install python 3.9
I can't find info on what `vm_enter_scope` does within hints in the cairo-lang repo
Why does range_check_ptr chek for [0, 2^128) instead of [0, P/2)
What are events in Cairo Language?
CairoLang error: `GatewayError: {'contract_address': ['Expected hex string, got:
What are a few of the best apps to test on starknet?
Which oracle service provider is StarkNet using?
How do I connect my DAPP to Starknet testnet using starknetjs?
Is Kakarot zkEVM a blockchain?
How many Cairo steps does it take to compute one Pedersen hash?