Skip to content
CCPEDIAby Unity Nodes
App Development

Print foldrA result

3 posts374 views10 likesLast activity Sep 2020

  1. carleslabonOP 3

    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
    
  2. cocreature 3

    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. carleslabon 4

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