SHARE
TWEET

Untitled

a guest Sep 12th, 2019 107 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Red[
  2.     Dialect: {
  3. pair! (req) - block size: record size x number of records
  4. [MAX] integer! (opt) - value size: string length for values in records. MAX
  5.                         switches to variable size
  6. }
  7. ]
  8.  
  9. make-string: func [
  10.     "Return random string!"
  11.     length [integer!] "String size"
  12. ][
  13.     collect/into [
  14.         loop length [keep random/only "abcdefghijklmnopqrstuvwxyz"]
  15.     ] make string! length
  16. ]
  17.  
  18. make-block: function [
  19.     "Make block of records from simple dialect"
  20.     desc [block!]
  21. ][
  22.     value-size: 8 ; default value size
  23.     variable-value-size?: false
  24.     record-size: 0
  25.     length: 0
  26.     parse desc [
  27.         set value pair! (
  28.             record-size: value/x
  29.             length: value/y
  30.         )
  31.         opt ['max (variable-value-size?: true)]
  32.         opt [set value-size integer!]
  33.     ]
  34.     collect/into [
  35.         loop length [
  36.             keep/only collect/into [
  37.                 loop record-size [
  38.                     keep make-string either variable-value-size? [
  39.                         random value-size
  40.                     ][
  41.                         value-size
  42.                     ]
  43.                 ]
  44.             ] make block! record-size
  45.         ]
  46.     ] make block! length
  47. ]
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top