Thursday 22 August 2013

How Operators: Infix, Prefix, Postfix, or Mixfix (Distfix)

How Operators: Infix, Prefix, Postfix, or Mixfix (Distfix)
Infix, prefix, postfix and Mixfix operators are different ways to write expressions equally.

Infix Notation

Operators are written in the middle of the operands

Examples

  • (6-5)*7
  • A*B + C/D

Prefix Notation

Also knowns as Polish notion. Operators are placed in the left of the operands

Examples

  • *(- 6 5) 7 or * - 6 5 7
  • + * A B / C D

Postfix Notation

Also knowns as Reverse Polish notion. Operators are placed in the right of the operands

Examples

  • 6 5 - 7 *
  • A B * C D / +

Outfix Notation

Operators are placed out of the operands

Examples

  • |_| in Maude, e.g. | 1 0 1 1 0 | is 5

Mixfix Notation

Have several name parts and can be infix, postfix, prefix, and closed (a).

References

Examples

  • if n + n == n ! then n else (n + n - n) in Agda: several name parts, mixed fixity (prefix, infix, postfix)
  • L ? S : T in Maude: comination of outfix and infix

Definition

  • Holes: denoted by _ in _[_]
  • Precedence
  • Infix _ + _: two holes and one name part +
  • Prefix if _ then _ else _: three name parts (if, then, else), and three holes.

Thursday 15 August 2013

[VIM] Insert the content of a file into current opened file


read a file and insert it into the position below the cursor of the current file

:read /path/to/file
:re /path/to/file
:r /path/to/file
  • insert into the beginning of the file
:0r /path/to/file
  • insert into the end of the file
:$r /path/to/file

read the output of system command and insert into the position below the cursor of the current file

  • read in the file list by ls command
      :r !ls
    
      :r !ls ~
  • read in the dir tree by tree command
      :r !tree

read a specific lines from a file and insert it into the position below the cursor of the current file

  • read the line no.10 to 20 into current file
:r !sed -n 10,20p /path/to/file