Skip to content

Latest commit

 

History

History
25 lines (20 loc) · 1.2 KB

ps-operators-b.md

File metadata and controls

25 lines (20 loc) · 1.2 KB

Operators: B

  1. begin: The begin operator marks the start of a code block in PostScript. It is often paired with end to enclose a section of code. For example:

    /myDict << /Name (John) /Age 30 >> begin
        % Code block
    end
    
  2. bind: The bind operator associates a name with a procedure. It's commonly used for creating higher-order functions or dynamically binding procedures to names. Example:

    /addTwo { 2 add } bind def
    3 addTwo   % Result: 5 (because 3 + 2 = 5)
    
  3. bitshift: The bitshift operator performs a bitwise shift operation on an integer. It shifts the bits of the first integer operand left (if the second operand is positive) or right (if the second operand is negative) by the number of bits specified by the absolute value of the second operand. Example:

    8 2 bitshift   % Result: 32 (because 8 << 2 = 32)
    
  4. bytesavailable: The bytesavailable operator returns the number of bytes available for reading from a file. It's typically used to check how much data is ready to be read from a file. Example:

    (myfile.txt) (r) file bytesavailable   % Result: Number of bytes available for reading from myfile.txt