Skip to main content
July 5, 2021
Question

How to print pattern below pattern.

  • July 5, 2021
  • 3 replies
  • 1 view

Please provide the code for printing the below pattern:

a

ab

abc

    3 replies

    stefanhelzle0001
    Brainy
    July 5, 2021

    Sorry, but why would I want to do that? Ask concrete questions and you will get support.

    What did you try? Do you have a specific question?

    Hint: Combine two nested foreach(), code() and enumerate().

    July 5, 2021

    I am also eager to know your use case. But this is how you would be able to create this pattern. You can take local!alphabet in a constant from A-Z and bring upto the letter for which you want to iterate it. In your case upto letter C.

     

    a!localVariables(
      local!alphabet: {
        "a",
        "b",
        "c",
        "d",
        "e",
        "f",
        "g",
        "h",
        "i",
        "j",
        "k",
        "l"
      },
      a!forEach(
        count(local!alphabet) - { enumerate(count(local!alphabet)) + 1 },
        concat(rdrop(local!alphabet, fv!item))
      )
    )

    ayushimAuthor
    July 5, 2021

    Thank you so much for your response.

    I was trying to implement patterns from other coding languages using SAIL functions. It is not related to any use case.