Mentions légales du service

Skip to content
Snippets Groups Projects

FizzBuzz in CUE

  • Clone with SSH
  • Clone with HTTPS
  • Embed
  • Share
    The snippet can be accessed without any authentication.
    Authored by PERDEREAU Eloi

    This FizzBuzz implementations in CUE, a simple example of a standard program written in a logic structural paradigm.

    In a few lines, we can elaborate on many CUE core concepts, e.g. emit values, hidden fields, if-then-else, comprehensions, embedding, lists, ...

    We can execute our program in the CLI with

    cue def fizzbuzz.cue | cat - <(echo '#max: 21') | cue export - --out=text

    The cat - <(echo '#max: 21') part adds to fizzbuzz.cue a refinement of the #max value, thus taking precedence on the default in the file. It is equivalent to having set some input parameters values to our CUE script.

    Edited
    fizzbuzz.cue 1.48 KiB
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Please register or to comment