⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.116
Server IP:
78.40.11.138
Server:
Linux tango.o2switch.net 4.18.0-553.30.1.lve.el8.x86_64 #1 SMP Tue Dec 3 01:21:19 UTC 2024 x86_64
Server Software:
Apache
PHP Version:
7.4.33
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
opt
/
alt
/
ruby33
/
share
/
ri
/
system
/
Numeric
/
Edit File: step-i.ri
U:RDoc::AnyMethod[iI" step:ETI"Numeric#step;TF:privateo:RDoc::Markup::Document:@parts[ o:RDoc::Markup::Verbatim; [MI"RGenerates a sequence of numbers; with a block given, traverses the sequence. ;TI" ;TI"/Of the Core and Standard Library classes, ;TI";Integer, Float, and Rational use this implementation. ;TI" ;TI"A quick example: ;TI" ;TI" squares = [] ;TI"6 1.step(by: 2, to: 10) {|i| squares.push(i*i) } ;TI"' squares # => [1, 9, 25, 49, 81] ;TI" ;TI"The generated sequence: ;TI" ;TI"- Begins with +self+. ;TI"?- Continues at intervals of +by+ (which may not be zero). ;TI"B- Ends with the last number that is within or equal to +to+; ;TI"@ that is, less than or equal to +to+ if +by+ is positive, ;TI": greater than or equal to +to+ if +by+ is negative. ;TI"= If +to+ is +nil+, the sequence is of infinite length. ;TI" ;TI"LIf a block is given, calls the block with each number in the sequence; ;TI"Wreturns +self+. If no block is given, returns an Enumerator::ArithmeticSequence. ;TI" ;TI"<b>Keyword Arguments</b> ;TI" ;TI"+With keyword arguments +by+ and +to+, ;TI">their values (or defaults) determine the step and limit: ;TI" ;TI" # Both keywords given. ;TI" squares = [] ;TI"@ 4.step(by: 2, to: 10) {|i| squares.push(i*i) } # => 4 ;TI"& squares # => [16, 36, 64, 100] ;TI" cubes = [] ;TI"@ 3.step(by: -1.5, to: -3) {|i| cubes.push(i*i*i) } # => 3 ;TI"6 cubes # => [27.0, 3.375, 0.0, -3.375, -27.0] ;TI" squares = [] ;TI"; 1.2.step(by: 0.2, to: 2.0) {|f| squares.push(f*f) } ;TI"N squares # => [1.44, 1.9599999999999997, 2.5600000000000005, 3.24, 4.0] ;TI" ;TI" squares = [] ;TI"E Rational(6/5).step(by: 0.2, to: 2.0) {|r| squares.push(r*r) } ;TI"S squares # => [1.0, 1.44, 1.9599999999999997, 2.5600000000000005, 3.24, 4.0] ;TI" ;TI" # Only keyword to given. ;TI" squares = [] ;TI"@ 4.step(to: 10) {|i| squares.push(i*i) } # => 4 ;TI"2 squares # => [16, 25, 36, 49, 64, 81, 100] ;TI" # Only by given. ;TI" ;TI" # Only keyword by given ;TI" squares = [] ;TI"> 4.step(by:2) {|i| squares.push(i*i); break if i > 10 } ;TI"+ squares # => [16, 36, 64, 100, 144] ;TI" ;TI" # No block given. ;TI"D e = 3.step(by: -1.5, to: -3) # => (3.step(by: -1.5, to: -3)) ;TI"H e.class # => Enumerator::ArithmeticSequence ;TI" ;TI"!<b>Positional Arguments</b> ;TI" ;TI"7With optional positional arguments +to+ and +by+, ;TI">their values (or defaults) determine the step and limit: ;TI" ;TI" squares = [] ;TI"8 4.step(10, 2) {|i| squares.push(i*i) } # => 4 ;TI"& squares # => [16, 36, 64, 100] ;TI" squares = [] ;TI"+ 4.step(10) {|i| squares.push(i*i) } ;TI"2 squares # => [16, 25, 36, 49, 64, 81, 100] ;TI" squares = [] ;TI"B 4.step {|i| squares.push(i*i); break if i > 10 } # => nil ;TI"7 squares # => [16, 25, 36, 49, 64, 81, 100, 121] ;T:@format0o:RDoc::Markup::Paragraph; [I" <b>Implementation Notes</b>;To:RDoc::Markup::BlankLine o; ; [I"KIf all the arguments are integers, the loop operates using an integer ;TI"counter. ;TI" ;TI"KIf any of the arguments are floating point numbers, all are converted ;TI")to floats, and the loop is executed ;TI"3<i>floor(n + n*Float::EPSILON) + 1</i> times, ;TI"*where <i>n = (limit - self)/step</i>.;T;0: @fileI"numeric.c;T:0@omit_headings_from_table_of_contents_below0I"pstep(to = nil, by = 1) {|n| ... } -> self step(to = nil, by = 1) -> enumerator step(to = nil, by: 1) {|n| ... } -> self step(to = nil, by: 1) -> enumerator step(by: 1, to: ) {|n| ... } -> self step(by: 1, to: ) -> enumerator step(by: , to: nil) {|n| ... } -> self step(by: , to: nil) -> enumerator ;T0[ I"(*args);T@bFI"Numeric;TcRDoc::NormalClass00
Simpan