Print foldrA result
App Development3 posts344 views10 likesLast activity Sep 2020
CA
carleslabonOP
Sep 2020Mod note: As of SDK 1.5.0 Scenarios have been superseded by the more powerful Daml Script. We now recommend using that for all purposes. For more information, and to learn how to use Script please check out @Andreas’ post on our blog.
Hello good evening. I was just wondering if we could print the value for “foldrA” for assertion purposes, since it doesn’t work within let & ← variable. Here is the code below, thanks!
import DA.NonEmpty
import DA.Action (when)
foldrA_test = scenario do
let
a = NonEmpty with
hd = 2
tl = [2, 4, 6]
foldrA (\x y -> do
when (x == y) (debug x)
return (y)) 6 a
CO
cocreature
Sep 2020You can definitely do that! You already found the debug statement which is printed to the transaction view in DAML Studio. To print the result of the foldrA use something like this:
foldrA_test = scenario do
let
a = NonEmpty with
hd = 2
tl = [2, 4, 6]
result <- foldrA (\x y -> do
when (x == y) (debug x)
return (y)) 6 a
debug result
CA
carleslabon
Sep 2020Oh I see, it worked on my end haha. Thanks! @cocreature.