clamp

force value within given range


Parameters

clamp number :integer :floating :rational
      range :block :range

Returns

  • :integer
  • :floating
  • :rational

Examples

copy
clamp 2 1..3 ; 2 clamp 0 1..3 ; 1 clamp 4 1..3 ; 3 clamp 4 3..1 ; 3 clamp 5 range.step: 2 0 5 ; 4 clamp 4.5 0..6 ; 4.5 clamp to :rational [1 5] 0..1 ; 1/5 clamp 4.5 [1 2.5] ; 2.5 clamp 2 [5 10] ; 5 clamp 2 [10 5] ; 5 clamp 2.5 @[1 to :rational [5 2]] ; 2.5

Related