Print foldrA result

Mod 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
3 Likes

You 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
3 Likes

Oh I see, it worked on my end haha. Thanks! @cocreature.

4 Likes