#encoding: utf-8 require 'y_support' # A tiny number of Unicode 1-character aliases: # # * ç – class (c with cedilla, U00E7) # * – singleton class (copyright sign) # * – square root # * Σ – summation # * Π – product # class Object alias :ç :class alias ⓒ singleton_class # Sum. The argument is expected to be a collection; block can be specified. # Basically same as chaining .reduce( :+ ) to the end; Σ() notation can be # more readable at times. # def Σ( collection ) collection.reduce { |acc, element| acc + ( block_given? ? yield( element ) : element ) } end # Product. The argument is expected to be a collection; block can be specified. # Basically same as chaining .reduce( :* ) to the end; Π() notation can be # more readable at times. # def Π( collection ) collection.reduce { |acc, element| acc * ( block_given? ? yield( element ) : element ) } end end # Defined aliases: # # * – alias for include # * ç for +class+ in several method names # class Module alias ★ include alias ç_variable_set class_variable_set alias ç_variable_get class_variable_get alias ç_variable_defined? class_variable_defined? alias remove_ç_variable remove_class_variable end # Defined aliases # # * – root of arbitrary degree ( x.√( n ) is n ** ( 1 / x ) ). # * sqrt as in +4.sqrt+ for square root (Math#sqrt). # class Numeric def √ number number ** ( 1.0 / self ) end # Square root (using Math#sqrt). # def sqrt Math.sqrt( self ) end end # Other abbreviations (eg. for local variables) are optionally encouraged: # # * ɱ – module (m with hook, U2C6E, compose seq. [m, j]) # * – hash (latin small letter heng, UA727, compose seq. [h, j]) # * – array (small capital A, U1D00, compose seq. [a, `]) # * ß – symbol (German sharp s, U00DF, compose seq. [s, s]) # * ς – string (Greek final sigma, U03C2, compose seq. [*, w]) # * w – abbreviation for "with" # * wo – abbreviation for "without" # # Note on compose sequences: # # Each compose sequence is preceded the key, whose location depends # on your system configuration. The sequences above comply with the standard # Kragen's .XCompose file (https://github.com/kragen/xcompose). In some cases, # the characters not in Kragen's file have to be defined manually for # comfortable typing.