Skip to content

Latest commit

 

History

History
130 lines (100 loc) · 3.61 KB

ps-operators-lmn.md

File metadata and controls

130 lines (100 loc) · 3.61 KB

Operators: L, M, N

  1. languagelevel: Returns the language level of the interpreter.

    languagelevel  % Might return 2 or 3 depending on the interpreter capabilities
    
  2. le: Compares two numbers and returns true if the first is less than or equal to the second.

    3 5 le  % Returns true
    
  3. length: Returns the number of elements in an array, dictionary, or the number of characters in a string.

    (Hello) length  % Returns 5
    
  4. limitcheck: Checks if an internal limit has been exceeded, usually within a context that might trigger this, such as image rendering.

  5. lineto: Adds a line from the current point to a specified point (x, y) in the current path.

    newpath 10 10 moveto 100 100 lineto  % Draws a line from (10,10) to (100,100)
    
  6. ln: Calculates the natural logarithm of a number.

    10 ln  % Calculates the natural log of 10
    
  7. load: Fetches the value associated with a name from the dictionary stack.

    /x 3 def x load  % Returns 3
    
  8. lock: Locks a given lock object to synchronize access in a concurrent environment.

  9. log: Computes the logarithm base 10 of a number.

    100 log  % Returns 2
    
  10. loop: Repeatedly executes a procedure.

    {1000 gt} {/count count 1 add def} loop  % Example loop structure; use within context
    
  11. lt: Tests if the first operand is less than the second.

    2 3 lt  % Returns true
    
  12. makefont: Creates a new font from an existing font by applying a transformation matrix.

    /Helvetica findfont [12 0 0 12 0 0] makefont setfont  % Makes and sets Helvetica at 12 point
    
  13. makepattern: Creates a pattern cell from a matrix and a painting procedure.

    [/Pattern /DeviceGray] setcolorspace
    [1 0 0 1 0 0] { ... } makepattern  % Example pattern definition
    
  14. mark: Pushes a mark onto the stack.

    mark
    
  15. matrix: Creates a transformation matrix or returns the default matrix if no parameters are given.

    matrix  % Returns an identity matrix
    
  16. maxlength: Returns the maximum length of a string, generally used to ensure capacity in operations.

    (Hello) maxlength  % Contextual use in handling strings
    
  17. mod: Computes the remainder of division between two integers.

    10 3 mod  % Returns 1
    
  18. monitor: Monitors a dictionary's access, executing a procedure if an event occurs.

  19. moveto: Moves the current point to the specified coordinates, starting a new subpath.

    100 200 moveto  % Moves the current point to (100,200)
    
  20. mul: Multiplies two numbers.

    2 3 mul  % Returns 6
    
  21. ne: Tests if two operands are not equal.

    2 3 ne  % Returns true
    
  22. neg: Negates a number.

    3 neg  % Returns -3
    
  23. newpath: Clears the current path.

    newpath  % Starts a new empty path
    
  24. noaccess: Marks an object so that it cannot be modified or executed.

  25. nocurrentpoint: Returns true if no current point is set on the path, often used in error handling.

  26. not: Logical NOT operator; inverts a boolean value.

    true not  % Returns false
    
  27. notify: Sends a notification to a condition object.

  28. null: Pushes a null object onto the stack.

    null  % Returns a null object
    
  29. nulldevice: Sets the output device to a null device, effectively disabling drawing operations.

    nulldevice  % Directs output to nowhere