This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Red [ | |
| author: {Maxim Velesyuk} | |
| usage: { | |
| abc-score? <block of code> | |
| abc-score? %file.red | |
| abc-score? :some-function | |
| } | |
| description: { | |
| The ABC software metric defines an ABC score as a triplet of values that represent the size of a set of source code statements. | |
| An ABC score is calculated by counting the number of assignments (A), number of branches (B), and number of conditionals (C) in a program. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| >> mal/parser/run "{1 2}" | |
| --> | |
| match: [(error: false) any whitespace collect [ahead "(" | |
| input: "{1 2}" | |
| match: [any whitespace collect [ahead "(" mal-list (probe | |
| input: "{1 2}" | |
| --> | |
| ==> matched | |
| <-- | |
| match: [whitespace collect [ahead "(" mal-list (probe "fo |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Red [] | |
| info: func ['fn /name /intro /args /refinements /locals /return /spec | |
| /arg-num /arg-names /arg-types /ref-names /ref-types /ref-num /type | |
| /local intr ars refs locs ret arg ref typ | |
| ][ | |
| intr: copy "" ars: make map! copy [] refs: make map! copy [] locs: copy [] ret: copy [] typ: ref-arg: ref-arg-type: none | |
| if lit-word? fn [fn: to-word fn] | |
| unless find [op! native! function! action!] type?/word get fn [ | |
| cause-error 'user 'message ["Only function types accepted!"] | |
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Red [ | |
| author: {Maxim Velesyuk} | |
| description: { | |
| A Snake Game / basic version | |
| specification by Edward de Jong, version 1 | |
| The game runs at 6 frames per second, and the snake moves one cell per frame. If the snake moves into the apple the length is increased by one, a crunch sound is emitted, and the apple is moved to a new cell. If the snake crosses over itself, then a beep is emitted and the part of the snake from that cell onward is erased. The snake wraps around the board in all four directions. | |
| The playing board, drawn solid black, is subdivided into square cells of 42 points at the screen resolution. Since the window size will not be an even number of cells, the cells are stretched slightly so that all screen space is used by the grid. At the start, the snake is set to length 1 and positioned at cell (4,4). The apple, which is the goal of the snake to eat, is one cell drawn as a circle in HTML color crimson, and is placed at a random location on the board. | |
| At the start of the game the snake is paused. A |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Red [ | |
| author: { Maxim Velesyuk } | |
| description: { | |
| colors palette showcase | |
| } | |
| ] | |
| sys-words: words-of system/words | |
| colors: copy [] | |
| forall sys-words [ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Red [] | |
| parser: context [ | |
| state: [] | |
| rules: [ | |
| any [ | |
| number! (append state 'number) | | |
| word! (append state 'word) | | |
| time! (append state 'time) | |
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Red [] | |
| { | |
| grammar HTML | |
| document <- (doctype / text / tag)* | |
| tag <- open_tag (text / tag)* close_tag | |
| open_tag <- "<" [0-9a-zA-Z \"'=-]+ ">" | |
| close_tag <- "</" [0-9a-zA-Z]+ ">" | |
| doctype <- "<!DOCTYPE " [0-9a-zA-Z]+ ">" | |
| text <- [^<]+ | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Red [ | |
| author: {Maxim Velesyuk} | |
| description: { | |
| Quick in-place function definitions without explicit arguments specification. | |
| `_` is next arugment, `_N` is N-th argument | |
| } | |
| ] | |
| inc: func ['word] [set word 1 + get word] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Red [ | |
| author: {Maxim Velesyuk} | |
| description: {draw dialect playground} | |
| ] | |
| demo: trim { | |
| fill-pen gray | |
| box 0x0 400x400 | |
| do [c: to-tuple reduce [ | |
| random 255 random 255 random 255] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| * (defun f (x y) (/ x y)) | |
| WARNING: redefining COMMON-LISP-USER::F in DEFUN | |
| F | |
| * (f 5 0) | |
| debugger invoked on a DIVISION-BY-ZERO in thread | |
| #<THREAD "main thread" RUNNING {100399C493}>: | |
| arithmetic error DIVISION-BY-ZERO signalled | |
| Operation was /, operands (5 0). |