Examples of an interesting computer programming paradigm.

  • hardkorebobOP
    link
    fedilink
    arrow-up
    2
    ·
    edit-2
    7 个月前
    Meta [
    	Title:   {Fizz Buzz math "game"}
    	Author:  "Kaj de Vos"
    	Rights:  "Copyright (c) 2021,2022 Kaj de Vos"
    	License: {
    		PD/CC0
    		http://creativecommons.org/publicdomain/zero/1.0/
    	}
    	Notes: {
    		https://en.wikipedia.org/wiki/Fizz_buzz
    		https://wiki.c2.com/?FizzBuzzTest
    		https://www.rosettacode.org/wiki/FizzBuzz
    	}
    ]
    
    For counter 100 [                                   ; Count to 100
        Third?: unless modulo counter 3 [write "Fizz"]  ; Display "Fizz" every third count; remember whether we did
    
        Any [
            unless modulo counter 5 [write "Buzz"]      ; Display "Buzz" every fifth count
            third?                                      ; Remember earlier result
            write counter                               ; Display the number if not third or fifth
        ]
        Write " "                                       ; Separate the displayed items
    ]
    Write new-line