tricu

An interpreted language for exploring Tree Calculus
Log | Files | Refs | README | LICENSE

rgb.tri (800B)


      1 !import bd2c14d6db6b69308a5252a8e839705a55d30e815f012900b094315263e08d81 *
      2 !import 7a24af56a9ce9b947cadcafd3a9da127b1507275bfac62b9fa55e27490b176dc as Binary
      3 !export main
      4 
      5 -- Validate an RGB list using the library's canonical-byte predicate.
      6 -- Try main [64 128 255], main [0 256 255], or main [0 1].
      7 -- Canonical encoding matters: redundant high zero bits are rejected too.
      8 -- List-shape errors are separate from invalid channels; checks short-circuit.
      9 main (t _) = "Expected a list."
     10 main [_ | (t _)] = "Expected a list."
     11 main [_ | [_ | (t _)]] = "Expected a list."
     12 main [r g b] = case and? (Binary.binaryByte? r) (and? (Binary.binaryByte? g) (Binary.binaryByte? b)) of
     13   ^true = "RGB triple accepted."
     14   _ = "A channel is not a canonical byte (0-255)."
     15 main _ = "Expected exactly three channels."