Module: Pyper::ControlCharacters
- Included in:
- PostfixMachine
- Defined in:
- lib/pyper/control_characters.rb,
lib/pyper/control_characters/other.rb,
lib/pyper/control_characters/cadr_like.rb,
lib/pyper/control_characters/greek_letters.rb,
lib/pyper/control_characters/other_latin_letters.rb
Overview
PostfixMachine mixin that defines the control characters.
Constant Summary collapse
- PREFIX_CHARACTERS =
['t'] << # letter t (for "to_something" methods) 'o' << # letter o (for operators) 'l' << # letter l (for literals) 'i' << # letter i 'ι' << # greek iota '¿' << # inverted question mark '‹' << # single left pointing quotation mark '›' << # single right pointing quotation mark '﹕' << # small colon '﹡'
Instance Method Summary collapse
-
#_ ⇒ Object
Explicit block closing.
-
#a ⇒ Object
In Pyper, ‘car’ becomes ‘τaτ’, and means second elements.
-
#A ⇒ Object
(also: #Α)
Latin capital letters ******************************************************************** Applies
#Arraymethod to the register. -
#B ⇒ Object
Makes the next block-enabled method receive the block that was supplied to the Pyper method.
-
#b ⇒ Object
Means second element.
-
#C ⇒ Object
Explicit parenthesizing of the current pipeline.
-
#c ⇒ Object
Means third element.
-
#d ⇒ Object
In Pyper, ‘cdr’ becomes ‘τdτ’.
-
#D ⇒ Object
Explicit dup-ping of the current pipeline (Giving up the original object and working with its
#dupinstead.). -
#E ⇒ Object
Equals operator (+:==+).
-
#e ⇒ Object
Means all except the first 2 elements.
-
#f ⇒ Object
Means all except the first 3 elements.
-
#G ⇒ Object
Ungrab the argument (unshift from pipeline).
-
#g ⇒ Object
Current pipe is assigned with the argument from the argument source.
-
#H ⇒ Object
A combo that switches this and other register, ungrabs the argument, and sets the other register as the argument source.
-
#h ⇒ Object
Other pipe is assigned with the argument from the argument source.
-
#I ⇒ Object
Braces method,
#[]. -
#iC ⇒ Object
Nullary method
#compact. -
#iE ⇒ Object
Nullary method bang (+#!+, exclamation mark operator).
-
#ij ⇒ Object
Nullary method join.
-
#im ⇒ Object
Unary - operator.
-
#iM ⇒ Object
Maps the other register to this register.
-
#ip ⇒ Object
Unary + operator.
-
#it ⇒ Object
Unary tilde operator.
-
#iX ⇒ Object
Map with index.
-
#ix ⇒ Object
Unary method
#index. -
#j ⇒ Object
Compiler directive that decrements the @arg_count index.
-
#J ⇒ Object
#joinexpecting argument. -
#l0 ⇒ Object
Pipe-resetting literal digit 0.
-
#l1 ⇒ Object
Pipe-resetting literal digit 1.
-
#l2 ⇒ Object
Pipe-resetting literal digit 2.
-
#l3 ⇒ Object
Pipe-resetting literal digit 3.
-
#l4 ⇒ Object
Pipe-resetting literal digit 4.
-
#l5 ⇒ Object
Pipe-resetting literal digit 5.
-
#l6 ⇒ Object
Pipe-resetting literal digit 6.
-
#l7 ⇒ Object
Pipe-resetting literal digit 7.
-
#l8 ⇒ Object
Pipe-resetting literal digit 8.
-
#l9 ⇒ Object
Pipe-resetting literal digit 9.
-
#lA ⇒ Object
Pipe-resetting literal empty array
[]. -
#lH ⇒ Object
Pipe-resetting literal empty hash {}.
-
#ln ⇒ Object
Pipe-resetting literal
nil. -
#lς ⇒ Object
Pipe-resetting literal empty string ”.
-
#m ⇒ Object
def m; nullary_method_with_block “map” end # All-important #map method.
-
#M ⇒ Object
Zip this and other register and invoke
#mapwith a binary block on it. -
#O ⇒ Object
Map this register with object from the other register as the starting contents of the delta pipeline, and epsilon as the argument source.
-
#o8 ⇒ Object
Pretzel operator (+#&+) method.
-
#oA ⇒ Object
Operator triple equals (+#===+).
-
#oa ⇒ Object
(also: #₊)
Addition as unary method.
-
#od ⇒ Object
(also: #÷)
Division as unary method.
-
#oG ⇒ Object
(also: #﹥)
Greater than as unary method.
-
#oI ⇒ Object
Pipe operator (+#|+) method.
-
#oi ⇒ Object
Unary method
#include?. -
#oM ⇒ Object
Modulo operator as unary method (also used for string interpolation).
-
#om ⇒ Object
(also: #★)
Multiplication as unary method.
-
#oO ⇒ Object
Or operator (+#||+, double pipe) method.
-
#op ⇒ Object
(also: #﹡﹡)
Power as unary method.
-
#oS ⇒ Object
(also: #﹤)
Smaller than as unary method.
-
#os ⇒ Object
(also: #₋)
Subtraction as unary method.
-
#p ⇒ Object
Adaptive prepend.
-
#q ⇒ Object
Adaptive append.
-
#r ⇒ Object
Pushes the secondary register (beta) onto the argument source stack.
-
#R ⇒ Object
Q: recursive piper method, end.
-
#s ⇒ Object
Sends the argument from the argument source to the current pipeline.
-
#T ⇒ Object
Ternary operator as binary method with the current pipeline as the receiver.
-
#tA ⇒ Object
Make a singleton array out of the current register.
-
#tf ⇒ Object
Stands for Float( register ).
-
#tH ⇒ Object
Zips this and other register to a hash.
-
#th ⇒ Object
Make a hash out of the current register.
-
#ti ⇒ Object
Stands for Integer( register ).
-
#ts ⇒ Object
Stands for
#to_s. -
#tS ⇒ Object
Stands for
#to_sym. -
#u ⇒ Object
Collection except the last 3 elements.
-
#U ⇒ Object
Unshift / prepend this register to the other register.
-
#v ⇒ Object
Collection except the last 2 elements.
-
#V ⇒ Object
unsh/prep self 2 reg (other changed).
-
#w ⇒ Object
Whole collection except the last element,.
-
#W ⇒ Object
Map zipped other and this register using binary block.
-
#x ⇒ Object
Means the third collection element from the end.
-
#X ⇒ Object
Swaps the contents of the primary (alpha) and the secondary (beta) register.
-
#y ⇒ Object
Means the penultimate collection element.
-
#z ⇒ Object
Means the last collection element.
-
#Z ⇒ Object
Zip this and other register.
-
#² ⇒ Object
Next block arity 2 selection.
-
#α ⇒ Object
Pushes the primary register (alpha) on the argument source stack.
-
#β ⇒ Object
Stashes the contents of the primary pipeline to the argument stack, and sets the secondary register as the argument source.
-
#γ ⇒ Object
A combo that switches this an the other register and sets the other register as the argument source.
-
#δ ⇒ Object
Pushes the in-block register (delta) on the argument source stack.
-
#ε ⇒ Object
Pushes the block argument register 1 (epsilon) on the argument source stack.
-
#ζ ⇒ Object
Pushes the block argument register 2 (zeta) on the argument source stack.
-
#ιA ⇒ Object
Argument-setting literal
[]. -
#ιG ⇒ Object
Greater or equal as unary method.
-
#ιH ⇒ Object
Argument-setting literal {}.
-
#ιI ⇒ Object
Braces equals method,
#[]=. -
#ιn ⇒ Object
Argument-setting literal
nil. -
#ιS ⇒ Object
Smaller or equal as unary method.
-
#ια ⇒ Object
When Greek iota (ι) is used as the prefix to the source selector, then rather then being pushed on the @argsrc stack, the new argument source replaces the topmost element of the stack.
- #ιβ ⇒ Object
-
#ιδ ⇒ Object
def ιγ; @argsrc.var! successor_register( @rr ) end.
- #ιε ⇒ Object
- #ιζ ⇒ Object
- #ιλ ⇒ Object
-
#ιρ ⇒ Object
Iota-prefixed rho (ιρ) resets the @argsrc stack to its default contents, that is, size 1 stack with
source::args_counted,grab_method::ref. -
#ις ⇒ Object
Argument-setting literal ”.
- #ιψ ⇒ Object
- #ιω ⇒ Object
- #ιΩ ⇒ Object
-
#λ ⇒ Object
Pushes onto the argument stack the default argument source, which is the “counted argument list” – Pyper method argument array indexed by compile-time @arg_count index.
-
#Π ⇒ Object
Capital pi (Π( sets the
:dupgrab mode for the top @argsrc element.. -
#ρ ⇒ Object
Small rho (ρ) sets the
:refgrab mode for the argument source stack – that is, turns off:shiftor:dupmode when active. -
#σ ⇒ Object
Small sigma sets the ‘shift’ grab mode for the top @argsrc element.
-
#ψ ⇒ Object
Pushes the penultimate element of the Pyper method argument array on the argument source stack.
-
#Ω ⇒ Object
Pushes onto the stack the whole array of the arguments passed to the pyper method, with
:shiftgrab method turned on by default. -
#ω ⇒ Object
Pushes the last element of the Pyper method argument array on the argument source stack.
-
#ᴘ ⇒ Object
make a pair.
-
#ⁱ ⇒ Object
Superscript i.
-
#∅ ⇒ Object
(also: #⊘, #ø)
Clear the current pipe (set to empty string):.
Instance Method Details
#_ ⇒ Object
Explicit block closing.
117 118 119 120 121 122 123 |
# File 'lib/pyper/control_characters/other.rb', line 117 def _ case @w # close block when in :block when :block then chain( close_block ) @w = :main if @rr.size == 1 unless @rr.empty? else raise "'_' (close block) used when not in block" end end |
#a ⇒ Object
In Pyper, ‘car’ becomes ‘τaτ’, and means second elements. Usable with strings, too.
7 8 9 10 11 12 |
# File 'lib/pyper/control_characters/cadr_like.rb', line 7 def a; pipe_2_variable; start "#@r =\n" + "if #@r.respond_to?( :first ) then #@r.first\n" + "elsif #@r.respond_to?( :[] ) then #@r[0]\n" + "else raise 'impossible to extract first element' end" start end |
#A ⇒ Object Also known as: Α
Latin capital letters ******************************************************************** Applies #Array method to the register.
89 90 91 92 |
# File 'lib/pyper/control_characters/other_latin_letters.rb', line 89 def A pipe_2_variable start "Array( #@r )" end |
#B ⇒ Object
Makes the next block-enabled method receive the block that was supplied to the Pyper method.
98 99 100 |
# File 'lib/pyper/control_characters/other_latin_letters.rb', line 98 def B @take_block = true unless @take_block == :taken end |
#b ⇒ Object
Means second element.
16 17 18 19 20 21 |
# File 'lib/pyper/control_characters/cadr_like.rb', line 16 def b; pipe_2_variable; start "#@r =\n" + "if #@r.respond_to?( :take ) then #@r.take(2)[1]\n" + "elsif #@r.respond_to?( :[] ) then #@r[1]\n" + "else raise 'unable to extract second collection element' end" start end |
#C ⇒ Object
Explicit parenthesizing of the current pipeline.
104 105 106 |
# File 'lib/pyper/control_characters/other_latin_letters.rb', line 104 def C parenthesize_current_pipeline end |
#c ⇒ Object
Means third element.
25 26 27 28 29 30 |
# File 'lib/pyper/control_characters/cadr_like.rb', line 25 def c; pipe_2_variable; start "#@r =\n" + "if #@r.respond_to?( :take ) then #@r.take(3)[2]\n" + "elsif #@r.respond_to?( :[] ) then #@r[2]\n" + "else raise 'unable to extract third collection element' end" start end |
#d ⇒ Object
In Pyper, ‘cdr’ becomes ‘τdτ’.
34 35 36 37 38 39 40 |
# File 'lib/pyper/control_characters/cadr_like.rb', line 34 def d; pipe_2_variable; start "#@r =\n" + "if #@r.is_a?( Hash ) then Hash[ @r.drop(1) ]\n" + "elsif #@r.respond_to?( :drop ) then #@r.drop(1)\n" + "elsif #@r.respond_to?( :[] ) then #@r[1..-1]\n" + "else raise 'unable to #drop(1) or #[1..-1]' end" start end |
#D ⇒ Object
Explicit dup-ping of the current pipeline (Giving up the original object and working with its #dup instead.)
111 112 113 |
# File 'lib/pyper/control_characters/other_latin_letters.rb', line 111 def D exe "#@r = #@r.dup" end |
#E ⇒ Object
Equals operator (+:==+).
117 118 119 |
# File 'lib/pyper/control_characters/other_latin_letters.rb', line 117 def E binary_operator "==" end |
#e ⇒ Object
Means all except the first 2 elements.
44 45 46 47 48 49 50 |
# File 'lib/pyper/control_characters/cadr_like.rb', line 44 def e; pipe_2_variable; start "#@r =\n" + "if #@r.is_a?( Hash ) then Hash[ @r.drop(2) ]\n" + "elsif #@r.respond_to?( :drop ) then #@r.drop(2)\n" + "elsif #@r.respond_to?( :[] ) then #@r[2..-1]\n" + "else raise 'unable to #drop(2) or #[2..-1]' end" start end |
#f ⇒ Object
Means all except the first 3 elements.
54 55 56 57 58 59 60 |
# File 'lib/pyper/control_characters/cadr_like.rb', line 54 def f; pipe_2_variable; start "#@r =\n" + "if #@r.is_a?( Hash ) then Hash[ @r.drop(3) ]\n" + "elsif #@r.respond_to?( :drop ) then #@r.drop(3)\n" + "elsif #@r.respond_to?( :[] ) then #@r[3..-1]\n" + "else raise 'unable to #drop(3) or #[3..-1]' end" start end |
#G ⇒ Object
Ungrab the argument (unshift from pipeline).
125 126 127 |
# File 'lib/pyper/control_characters/other_latin_letters.rb', line 125 def G exe "args.unshift #@r" end |
#g ⇒ Object
Current pipe is assigned with the argument from the argument source.
6 7 8 |
# File 'lib/pyper/control_characters/other_latin_letters.rb', line 6 def g set grab_arg end |
#H ⇒ Object
A combo that switches this and other register, ungrabs the argument, and sets the other register as the argument source.
132 133 134 135 |
# File 'lib/pyper/control_characters/other_latin_letters.rb', line 132 def H X() β() end |
#h ⇒ Object
Other pipe is assigned with the argument from the argument source.
12 13 14 15 16 |
# File 'lib/pyper/control_characters/other_latin_letters.rb', line 12 def h exe "#@r, #{successor_register(@r)} = #{successor_register(@r)}, #@r" set grab_arg exe "#@r, #{successor_register(@r)} = #{successor_register(@r)}, #@r" end |
#I ⇒ Object
Braces method, #[].
139 140 141 |
# File 'lib/pyper/control_characters/other_latin_letters.rb', line 139 def I @pipe[-1] << "[#{grab_arg}]" end |
#iC ⇒ Object
Nullary method #compact.
36 37 38 |
# File 'lib/pyper/control_characters/other.rb', line 36 def iC nullary_method "compact" end |
#iE ⇒ Object
Nullary method bang (+#!+, exclamation mark operator).
42 43 44 |
# File 'lib/pyper/control_characters/other.rb', line 42 def iE unary_operator '!' end |
#ij ⇒ Object
Nullary method join.
6 7 8 |
# File 'lib/pyper/control_characters/other.rb', line 6 def ij chain "join" end |
#im ⇒ Object
Unary - operator.
18 19 20 |
# File 'lib/pyper/control_characters/other.rb', line 18 def im unary_operator "-" end |
#iM ⇒ Object
Maps the other register to this register.
127 128 129 130 131 |
# File 'lib/pyper/control_characters/other.rb', line 127 def iM pipe_2_variable start "#{successor_register(@r)}" nullary_method_with_block "map" end |
#ip ⇒ Object
Unary + operator.
12 13 14 |
# File 'lib/pyper/control_characters/other.rb', line 12 def ip unary_operator "+" end |
#it ⇒ Object
Unary tilde operator.
24 25 26 |
# File 'lib/pyper/control_characters/other.rb', line 24 def it unary_operator "~" end |
#iX ⇒ Object
Map with index
48 49 50 51 52 |
# File 'lib/pyper/control_characters/other.rb', line 48 def iX next_block_will_be_binary nullary_method "map" nullary_method_with_block "with_index" end |
#ix ⇒ Object
Unary method #index.
30 31 32 |
# File 'lib/pyper/control_characters/other.rb', line 30 def ix unary_method "index" end |
#j ⇒ Object
Compiler directive that decrements the @arg_count index. With :args_counted argument source, when used once, causes the same argument to be taken twice. When used twice or more, causes the same number of argument array elements to be taken twice.
23 24 25 |
# File 'lib/pyper/control_characters/other_latin_letters.rb', line 23 def j @arg_count -= 1 end |
#J ⇒ Object
#join expecting argument.
148 149 150 |
# File 'lib/pyper/control_characters/other_latin_letters.rb', line 148 def J unary_method "join" end |
#l0 ⇒ Object
Pipe-resetting literal digit 0.
317 318 319 |
# File 'lib/pyper/control_characters/other.rb', line 317 def l0 set "0" end |
#l1 ⇒ Object
Pipe-resetting literal digit 1.
323 324 325 |
# File 'lib/pyper/control_characters/other.rb', line 323 def l1 set "1" end |
#l2 ⇒ Object
Pipe-resetting literal digit 2.
329 330 331 |
# File 'lib/pyper/control_characters/other.rb', line 329 def l2 set "2" end |
#l3 ⇒ Object
Pipe-resetting literal digit 3.
335 336 337 |
# File 'lib/pyper/control_characters/other.rb', line 335 def l3 set "3" end |
#l4 ⇒ Object
Pipe-resetting literal digit 4.
341 342 343 |
# File 'lib/pyper/control_characters/other.rb', line 341 def l4 set "4" end |
#l5 ⇒ Object
Pipe-resetting literal digit 5.
347 348 349 |
# File 'lib/pyper/control_characters/other.rb', line 347 def l5 set "5" end |
#l6 ⇒ Object
Pipe-resetting literal digit 6.
353 354 355 |
# File 'lib/pyper/control_characters/other.rb', line 353 def l6 set "6" end |
#l7 ⇒ Object
Pipe-resetting literal digit 7.
359 360 361 |
# File 'lib/pyper/control_characters/other.rb', line 359 def l7 set "7" end |
#l8 ⇒ Object
Pipe-resetting literal digit 8.
365 366 367 |
# File 'lib/pyper/control_characters/other.rb', line 365 def l8 set "8" end |
#l9 ⇒ Object
Pipe-resetting literal digit 9.
371 372 373 |
# File 'lib/pyper/control_characters/other.rb', line 371 def l9 set "9" end |
#lA ⇒ Object
Pipe-resetting literal empty array [].
305 306 307 |
# File 'lib/pyper/control_characters/other.rb', line 305 def lA set '[]' end |
#lH ⇒ Object
Pipe-resetting literal empty hash {}.
311 312 313 |
# File 'lib/pyper/control_characters/other.rb', line 311 def lH set '{}' end |
#ln ⇒ Object
Pipe-resetting literal nil.
293 294 295 |
# File 'lib/pyper/control_characters/other.rb', line 293 def ln set "nil" end |
#lς ⇒ Object
Pipe-resetting literal empty string ”.
299 300 301 |
# File 'lib/pyper/control_characters/other.rb', line 299 def lς set '' end |
#m ⇒ Object
def m; nullary_method_with_block “map” end # All-important #map method
33 34 35 36 37 38 |
# File 'lib/pyper/control_characters/other_latin_letters.rb', line 33 def m pipe_2_variable start "if #@r.is_a? String then #@r = #@r.each_char end\n" start nullary_method_with_block "map" end |
#M ⇒ Object
Zip this and other register and invoke #map with a binary block on it.
158 159 160 161 162 163 |
# File 'lib/pyper/control_characters/other_latin_letters.rb', line 158 def M next_block_will_be_binary pipe_2_variable start "#@r.zip(#{successor_register(@r)})" nullary_method_with_block "map" end |
#O ⇒ Object
Map this register with object from the other register as the starting contents of the delta pipeline, and epsilon as the argument source.
170 171 172 173 174 175 |
# File 'lib/pyper/control_characters/other_latin_letters.rb', line 170 def O r() m() g() ε() end |
#o8 ⇒ Object
Pretzel operator (+#&+) method.
226 227 228 |
# File 'lib/pyper/control_characters/other.rb', line 226 def o8 binary_operator "&" end |
#oA ⇒ Object
Operator triple equals (+#===+).
182 183 184 |
# File 'lib/pyper/control_characters/other.rb', line 182 def oA binary_operator "&&" end |
#oa ⇒ Object Also known as: ₊
Addition as unary method.
141 142 143 |
# File 'lib/pyper/control_characters/other.rb', line 141 def oa binary_operator "+" end |
#od ⇒ Object Also known as: ÷
Division as unary method.
168 169 170 |
# File 'lib/pyper/control_characters/other.rb', line 168 def od binary_operator "/" end |
#oG ⇒ Object Also known as: ﹥
Greater than as unary method.
207 208 209 |
# File 'lib/pyper/control_characters/other.rb', line 207 def oG binary_operator ">" end |
#oI ⇒ Object
Pipe operator (+#|+) method.
194 195 196 |
# File 'lib/pyper/control_characters/other.rb', line 194 def oI binary_operator "|" end |
#oi ⇒ Object
Unary method #include?.
148 149 150 |
# File 'lib/pyper/control_characters/other.rb', line 148 def oi unary_method "include?" end |
#oM ⇒ Object
Modulo operator as unary method (also used for string interpolation).
214 215 216 |
# File 'lib/pyper/control_characters/other.rb', line 214 def oM binary_operator "%" end |
#om ⇒ Object Also known as: ★
Multiplication as unary method.
161 162 163 |
# File 'lib/pyper/control_characters/other.rb', line 161 def om binary_operator "*" end |
#oO ⇒ Object
Or operator (+#||+, double pipe) method.
220 221 222 |
# File 'lib/pyper/control_characters/other.rb', line 220 def oO binary_operator "||" end |
#op ⇒ Object Also known as: ﹡﹡
Power as unary method.
175 176 177 |
# File 'lib/pyper/control_characters/other.rb', line 175 def op binary_operator "**" end |
#oS ⇒ Object Also known as: ﹤
Smaller than as unary method.
200 201 202 |
# File 'lib/pyper/control_characters/other.rb', line 200 def oS binary_operator "<" end |
#os ⇒ Object Also known as: ₋
Subtraction as unary method.
154 155 156 |
# File 'lib/pyper/control_characters/other.rb', line 154 def os binary_operator "-" end |
#p ⇒ Object
Adaptive prepend.
45 46 47 48 49 50 51 52 53 54 |
# File 'lib/pyper/control_characters/other_latin_letters.rb', line 45 def p pipe_2_variable; arg = grab_arg; start "#@r =\n" + # arg 2 self "if #@r.respond_to?( :unshift ) then #@r.unshift(#{arg})\n" + "elsif #@r.respond_to?( :prepend ) then #@r.prepend(#{arg})\n" + "elsif #@r.respond_to?( :merge ) and #@r.is_a?( Array ) " + "&& #@r.size == 2\nHash[*#@r].merge(#{arg})\n" + "elsif #@r.respond_to? :merge then #@r.merge(#{arg})\n" + "else raise 'impossible to unshift/prepend' end" start end |
#q ⇒ Object
Adaptive append.
58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/pyper/control_characters/other_latin_letters.rb', line 58 def q pipe_2_variable arg = grab_arg start "#@r =\n" + # arg 2 self "if #@r.respond_to?( :<< ) then #@r << #{arg}\n" + "elsif #@r.respond_to?( :merge ) and #@r.is_a?(Array) " + "&& #@r.size == 2\n#{arg}.merge(Hash[*#@r])\n" + "elsif #@r.respond_to?( :merge ) then #{arg}.merge(#@r)\n" + "else raise 'impossible to <</append' end" start end |
#r ⇒ Object
Pushes the secondary register (beta) onto the argument source stack.
72 73 74 |
# File 'lib/pyper/control_characters/other_latin_letters.rb', line 72 def r @argsrc.beta end |
#R ⇒ Object
Q: recursive piper method, end
181 182 183 184 |
# File 'lib/pyper/control_characters/other_latin_letters.rb', line 181 def R # Reverse zip: Zip other and this register pipe_2_variable start "#{successor_register}.zip(#@a)" end |
#s ⇒ Object
Sends the argument from the argument source to the current pipeline.
78 79 80 81 |
# File 'lib/pyper/control_characters/other_latin_letters.rb', line 78 def s pipe_2_variable start "#@r.send( *(#{grab_arg}) )" end |
#T ⇒ Object
Ternary operator as binary method with the current pipeline as the receiver.
190 191 192 193 |
# File 'lib/pyper/control_characters/other_latin_letters.rb', line 190 def T parenthesize_current_pipeline @pipe[-1] << " ? ( #{grab_arg} ) : ( #{grab_arg} )" end |
#tA ⇒ Object
Make a singleton array out of the current register. (“Array( register ) is invoked simply by capital A without prefixes.)
84 85 86 87 |
# File 'lib/pyper/control_characters/other.rb', line 84 def tA pipe_2_variable start "[#@r]" end |
#tf ⇒ Object
Stands for Float( register ).
56 57 58 59 |
# File 'lib/pyper/control_characters/other.rb', line 56 def tf pipe_2_variable start "Float( #@r )" end |
#tH ⇒ Object
Zips this and other register to a hash.
91 92 93 94 |
# File 'lib/pyper/control_characters/other.rb', line 91 def tH pipe_2_variable start "Hash[ #@r.zip( #{successor_register( @r )} ) ]" end |
#th ⇒ Object
Make a hash out of the current register.
63 64 65 66 |
# File 'lib/pyper/control_characters/other.rb', line 63 def th pipe_2_variable start "Hash[ #@r.zip( #{successor_register(@r)} ) ]" end |
#ti ⇒ Object
Stands for Integer( register ).
70 71 72 73 |
# File 'lib/pyper/control_characters/other.rb', line 70 def ti pipe_2_variable start "Integer( #@r )" end |
#ts ⇒ Object
Stands for #to_s.
77 78 79 |
# File 'lib/pyper/control_characters/other.rb', line 77 def ts nullary_method "to_s" end |
#tS ⇒ Object
Stands for #to_sym.
98 99 100 |
# File 'lib/pyper/control_characters/other.rb', line 98 def tS nullary_method "to_sym" end |
#u ⇒ Object
Collection except the last 3 elements.
111 112 113 114 115 116 117 |
# File 'lib/pyper/control_characters/cadr_like.rb', line 111 def u; pipe_2_variable; start "#@r =\n" + "if #@r.is_a?( Hash ) then Hash[ @r.take( #@r.size - 3 ) ]\n" + "elsif #@r.respond_to?( :take ) then #@r.take( #@r.size - 3 )\n" + "elsif #@r.respond_to?( :[] ) then #@r[0...-3]\n" + "else raise 'unable to #drop(1) or #[1...-3]' end" start end |
#U ⇒ Object
Unshift / prepend this register to the other register.
197 |
# File 'lib/pyper/control_characters/other_latin_letters.rb', line 197 def U; end |
#v ⇒ Object
Collection except the last 2 elements.
101 102 103 104 105 106 107 |
# File 'lib/pyper/control_characters/cadr_like.rb', line 101 def v; pipe_2_variable; start "#@r =\n" + "if #@r.is_a?( Hash ) then Hash[ @r.take( #@r.size - 2 ) ]\n" + "elsif #@r.respond_to?( :take ) then #@r.take( #@r.size - 2 )\n" + "elsif #@r.respond_to?( :[] ) then #@r[0...-2]\n" + "else raise 'unable to #drop(1) or #[1...-2]' end" start end |
#V ⇒ Object
unsh/prep self 2 reg (other changed)
199 |
# File 'lib/pyper/control_characters/other_latin_letters.rb', line 199 def V; end |
#w ⇒ Object
Whole collection except the last element,
91 92 93 94 95 96 97 |
# File 'lib/pyper/control_characters/cadr_like.rb', line 91 def w; pipe_2_variable; start "#@r =\n" + "if #@r.is_a?( Hash ) then Hash[ @r.take( #@r.size - 1 ) ]\n" + "elsif #@r.respond_to?( :take ) then #@r.take( #@r.size - 1 )\n" + "elsif #@r.respond_to?( :[] ) then #@r[0...-1]\n" + "else raise 'unable to #drop(1) or #[1...-1]' end" start end |
#W ⇒ Object
Map zipped other and this register using binary block.
203 204 205 206 207 208 |
# File 'lib/pyper/control_characters/other_latin_letters.rb', line 203 def W next_block_will_be_binary # Mnemonic: W is inverted M pipe_2_variable start "#{successor_register(@r)}.zip(#@r)" nullary_method_with_block "map" end |
#x ⇒ Object
Means the third collection element from the end.
82 83 84 85 86 87 |
# File 'lib/pyper/control_characters/cadr_like.rb', line 82 def x; pipe_2_variable; start "#@r =\n" + "if #@r.respond_to?( :drop ) then #@r.drop( #@r.size - 3 ).first\n" + "elsif #@r.respond_to?( :[] ) then #@r[-3]\n" + "else raise 'unable to extract third-from-the-end element' end" start end |
#X ⇒ Object
Swaps the contents of the primary (alpha) and the secondary (beta) register.
212 213 214 215 216 217 218 |
# File 'lib/pyper/control_characters/other_latin_letters.rb', line 212 def X case @w when :block then raise "'χ' (swap pipes) may not be used in blocks!" else exe "#@r, #{successor_register} = #{successor_register}, #@r" end end |
#y ⇒ Object
Means the penultimate collection element.
73 74 75 76 77 78 |
# File 'lib/pyper/control_characters/cadr_like.rb', line 73 def y; pipe_2_variable; start "#@r =\n" + "if #@r.respond_to?( :drop ) then #@r.drop( #@r.size - 2 ).first\n" + "elsif #@r.respond_to?( :[] ) then #@r[-2]\n" + "else raise 'unable to extract second-from-the-end element' end" start end |
#z ⇒ Object
Means the last collection element.
64 65 66 67 68 69 |
# File 'lib/pyper/control_characters/cadr_like.rb', line 64 def z; pipe_2_variable; start "#@r =\n" + "if #@r.respond_to?( :drop ) then #@r.drop( #@r.size - 1 ).first\n" + "elsif #@r.respond_to?( :[] ) then #@r[-1]\n" + "else raise 'unable to extract last element' end" start end |
#Z ⇒ Object
Zip this and other register.
224 225 226 227 |
# File 'lib/pyper/control_characters/other_latin_letters.rb', line 224 def Z pipe_2_variable start "#@r.zip(#{successor_register})" end |
#² ⇒ Object
Next block arity 2 selection
110 |
# File 'lib/pyper/control_characters/other.rb', line 110 def ²; block_2ary end |
#α ⇒ Object
Pushes the primary register (alpha) on the argument source stack.
6 7 8 |
# File 'lib/pyper/control_characters/greek_letters.rb', line 6 def α @argsrc.alpha end |
#β ⇒ Object
Stashes the contents of the primary pipeline to the argument stack, and sets the secondary register as the argument source.
13 14 15 16 |
# File 'lib/pyper/control_characters/greek_letters.rb', line 13 def β G() r() end |
#γ ⇒ Object
A combo that switches this an the other register and sets the other register as the argument source.
21 22 23 24 |
# File 'lib/pyper/control_characters/greek_letters.rb', line 21 def γ X() r() end |
#δ ⇒ Object
Pushes the in-block register (delta) on the argument source stack.
28 29 30 |
# File 'lib/pyper/control_characters/greek_letters.rb', line 28 def δ @argsrc.delta end |
#ε ⇒ Object
Pushes the block argument register 1 (epsilon) on the argument source stack.
34 35 36 |
# File 'lib/pyper/control_characters/greek_letters.rb', line 34 def ε @argsrc.epsilon end |
#ζ ⇒ Object
Pushes the block argument register 2 (zeta) on the argument source stack.
40 41 42 |
# File 'lib/pyper/control_characters/greek_letters.rb', line 40 def ζ @argsrc.zeta end |
#ιA ⇒ Object
Argument-setting literal [].
281 282 283 |
# File 'lib/pyper/control_characters/other.rb', line 281 def ιA exe "args.unshift %s" % '[]' end |
#ιG ⇒ Object
Greater or equal as unary method.
238 239 240 |
# File 'lib/pyper/control_characters/other.rb', line 238 def ιG binary_operator ">=" end |
#ιH ⇒ Object
Argument-setting literal {}.
287 288 289 |
# File 'lib/pyper/control_characters/other.rb', line 287 def ιH exe "args.unshift %s" % '{}' end |
#ιI ⇒ Object
Braces equals method, #[]=.
244 245 246 |
# File 'lib/pyper/control_characters/other.rb', line 244 def ιI @pipe[-1] << "[#{grab_arg}] = #{grab_arg}" end |
#ιn ⇒ Object
Argument-setting literal nil.
269 270 271 |
# File 'lib/pyper/control_characters/other.rb', line 269 def ιn exe "args.unshift %s" % "nil" end |
#ιS ⇒ Object
Smaller or equal as unary method.
232 233 234 |
# File 'lib/pyper/control_characters/other.rb', line 232 def ιS binary_operator "<=" end |
#ια ⇒ Object
When Greek iota (ι) is used as the prefix to the source selector, then rather then being pushed on the @argsrc stack, the new argument source replaces the topmost element of the stack. When the stack size is 1, this has the additional effect of setting the given argument source as default, until another such change happens, or stack reset is performed.
98 99 100 |
# File 'lib/pyper/control_characters/greek_letters.rb', line 98 def ια @argsrc.alpha! end |
#ιβ ⇒ Object
102 103 104 |
# File 'lib/pyper/control_characters/greek_letters.rb', line 102 def ιβ @argsrc.beta! end |
#ιδ ⇒ Object
def ιγ; @argsrc.var! successor_register( @rr ) end
108 109 110 |
# File 'lib/pyper/control_characters/greek_letters.rb', line 108 def ιδ @argsrc.delta! end |
#ιε ⇒ Object
112 113 114 |
# File 'lib/pyper/control_characters/greek_letters.rb', line 112 def ιε @argsrc.epsilon! end |
#ιζ ⇒ Object
116 117 118 |
# File 'lib/pyper/control_characters/greek_letters.rb', line 116 def ιζ @argsrc.zeta! end |
#ιλ ⇒ Object
135 136 137 |
# File 'lib/pyper/control_characters/greek_letters.rb', line 135 def ιλ @argsrc.args_counted! end |
#ιρ ⇒ Object
Iota-prefixed rho (ιρ) resets the @argsrc stack to its default contents, that is, size 1 stack with source: :args_counted, grab_method: :ref.
123 124 125 |
# File 'lib/pyper/control_characters/greek_letters.rb', line 123 def ιρ @argsrc.std! end |
#ις ⇒ Object
Argument-setting literal ”.
275 276 277 |
# File 'lib/pyper/control_characters/other.rb', line 275 def ις; exe "args.unshift %s" % '' end |
#ιψ ⇒ Object
127 128 129 |
# File 'lib/pyper/control_characters/greek_letters.rb', line 127 def ιψ @argsrc.psi! end |
#ιω ⇒ Object
131 132 133 |
# File 'lib/pyper/control_characters/greek_letters.rb', line 131 def ιω @argsrc.omega! end |
#ιΩ ⇒ Object
139 140 141 |
# File 'lib/pyper/control_characters/greek_letters.rb', line 139 def ιΩ @argsrc.args! end |
#λ ⇒ Object
Pushes onto the argument stack the default argument source, which is the “counted argument list” – Pyper method argument array indexed by compile-time @arg_count index.
48 49 50 |
# File 'lib/pyper/control_characters/greek_letters.rb', line 48 def λ @argsrc.args_counted end |
#Π ⇒ Object
Capital pi (Π( sets the :dup grab mode for the top @argsrc element.
81 82 83 |
# File 'lib/pyper/control_characters/greek_letters.rb', line 81 def Π @argsrc.dup! end |
#ρ ⇒ Object
Small rho (ρ) sets the :ref grab mode for the argument source stack – that is, turns off :shift or :dup mode when active.
69 70 71 |
# File 'lib/pyper/control_characters/greek_letters.rb', line 69 def ρ @argsrc.ref! end |
#σ ⇒ Object
Small sigma sets the ‘shift’ grab mode for the top @argsrc element.
75 76 77 |
# File 'lib/pyper/control_characters/greek_letters.rb', line 75 def σ @argsrc.shift! end |
#ψ ⇒ Object
Pushes the penultimate element of the Pyper method argument array on the argument source stack.
55 56 57 |
# File 'lib/pyper/control_characters/greek_letters.rb', line 55 def ψ @argsrc.psi end |
#Ω ⇒ Object
Pushes onto the stack the whole array of the arguments passed to the pyper method, with :shift grab method turned on by default.
88 89 90 |
# File 'lib/pyper/control_characters/greek_letters.rb', line 88 def Ω @argsrc.args end |
#ω ⇒ Object
Pushes the last element of the Pyper method argument array on the argument source stack.
62 63 64 |
# File 'lib/pyper/control_characters/greek_letters.rb', line 62 def ω @argsrc.omega end |
#ᴘ ⇒ Object
make a pair
133 134 135 136 137 |
# File 'lib/pyper/control_characters/other.rb', line 133 def ᴘ # make a pair pipe_2_variable arg = grab_arg start "[#@r, #{arg}]" end |
#ⁱ ⇒ Object
Superscript i. Next block will have arity 2 and will be written with inverse parameter order.
114 |
# File 'lib/pyper/control_characters/other.rb', line 114 def ⁱ; block_2ary_swapped end |
#∅ ⇒ Object Also known as: ⊘, ø
Clear the current pipe (set to empty string):
376 |
# File 'lib/pyper/control_characters/other.rb', line 376 def ∅; set "" end |