NEWTON
Asked
8 months ago
62
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
8 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
8 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)
Implementing the connect wallet. Can you help about connectors?
Why abi of warp compiled contract does not match original solidity abi?
Are there rewards for running a Pathfinder node?
StarknetErrorCode.DEPRECATED_TRANSACTION while deploying StarkNet contract
How to verify Empiric’s Data Entries Using Events?
Questions about useStarknetExecute. Do we update the transaction manager on our end? [StarkNet/Cairo]
What is the technical difference of Kakarot compare to Nethermind's Warp?