|
|
||
|
|
Start of topic | Skip to actions
Solution: Color Functions
; color-complement : symbol -> symbol
;
; Purpose: Returns the name of the color complementary to the
; input color.
(define (color-complement color)
(cond
[(symbol=? color 'green) 'red]
[(symbol=? color 'red) 'green]
[(symbol=? color 'violet) 'yellow]
[(symbol=? color 'yellow) 'violet]
[(symbol=? color 'orange) 'blue]
[(symbol=? color 'blue) 'orange]))
'color-complement_examples
(symbol=? (color-complement 'green) 'red)
(symbol=? (color-complement 'red) 'green)
(symbol=? (color-complement 'yellow) 'violet)
(symbol=? (color-complement 'violet) 'yellow)
(symbol=? (color-complement 'orange) 'blue)
(symbol=? (color-complement 'blue) 'orange)
; color-primary? : symbol -> boolean
;
; Purpose: Returns whether the color is a primary color or not.
(define (color-primary? color)
(cond
[(symbol=? color 'green) false]
[(symbol=? color 'red) true]
[(symbol=? color 'violet) false]
[(symbol=? color 'yellow) false]
[(symbol=? color 'orange) false]
[(symbol=? color 'blue) true]))
'color-primary?_examples
(boolean=? (color-primary? 'green) false)
(boolean=? (color-primary? 'red) true)
(boolean=? (color-primary? 'yellow) false)
(boolean=? (color-primary? 'violet) false)
(boolean=? (color-primary? 'orange) false)
(boolean=? (color-primary? 'blue) true)
Access Permissions
Topic Actions: Edit | Attach | Printable | Raw View | Backlinks: Web, All Webs | History: r2 < r1 | More topic actions
Webs: Main | TWiki | Africa | EmbeddedSystems | Gpce | Houston | International | K12 | MetaOCaml | MulticoreOCR | ProgrammingLanguages | RAP | RIDL | Sandbox | SpeechClub | Teaching | Texbot | WG211 Web Actions: |
|
This work is licensed under a Creative Commons Attribution 2.5 License. Please follow our citation guidelines.