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