⚝
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
/
ruby19
/
share
/
ri
/
1.9.1
/
system
/
Enumerable
/
Edit File: reduce-i.ri
U:RDoc::AnyMethod[iI"reduce:ETI"Enumerable#reduce;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I">Combines all elements of <i>enum</i> by applying a binary;TI"=operation, specified by a block or a symbol that names a;TI"method or operator.;To:RDoc::Markup::BlankLine o; ; [I"AIf you specify a block, then for each element in <i>enum</i>;TI"Lthe block is passed an accumulator value (<i>memo</i>) and the element.;TI"IIf you specify a symbol instead, then each element in the collection;TI"7will be passed to the named method of <i>memo</i>.;TI"FIn either case, the result becomes the new value for <i>memo</i>.;TI"GAt the end of the iteration, the final value of <i>memo</i> is the;TI"!return value for the method.;T@o; ; [I"NIf you do not explicitly specify an <i>initial</i> value for <i>memo</i>,;TI"Kthen uses the first element of collection is used as the initial value;TI"of <i>memo</i>.;T@o; ; [I"Examples:;T@o:RDoc::Markup::Verbatim; [I"# Sum some numbers ;FI":(5..10).reduce(:+) #=> 45 ;FI"%# Same using a block and inject ;FI":(5..10).inject {|sum, n| sum + n } #=> 45 ;FI"# Multiply some numbers ;FI">(5..10).reduce(1, :*) #=> 151200 ;FI"# Same using a block ;FI">(5..10).inject(1) {|product, n| product * n } #=> 151200 ;FI"# find the longest word ;FI":longest = %w{ cat sheep bear }.inject do |memo,word| ;FI"0 memo.length > word.length ? memo : word ;FI" end ;FI">longest #=> "sheep";F: @file0I"Uenum.inject(initial, sym) -> obj enum.inject(sym) -> obj enum.inject(initial) {| memo, obj | block } -> obj enum.inject {| memo, obj | block } -> obj enum.reduce(initial, sym) -> obj enum.reduce(sym) -> obj enum.reduce(initial) {| memo, obj | block } -> obj enum.reduce {| memo, obj | block } -> obj ;T0[ I"(p1 = v1, p2 = v2);FI"enum.c;T
Simpan