fork(1) download
  1. type rgb = {r: int; g: int; b: int};;
  2. type color = Red | Green | Blue | Rgb of rgb;;
  3.  
  4. let to_hex(color : color) : string =
  5. match color with
  6. Red -> "#FF000"
  7. | Green -> "#00FF00"
  8. | Blue -> "#0000FF"
  9. | Rgb {r; g; b} -> Printf.sprintf "#%02X%02X%02X" r g b;;
  10.  
  11. let white = Rgb { r=255; g=255; b=255 };;
  12. print_string(to_hex(white));;
  13.  
Success #stdin #stdout 0s 4196KB
stdin
Standard input is empty
stdout
#FFFFFF