• Complain

Jay Godse [Jay Godse] - Ruby Data Processing: Using Map, Reduce, and Select

Here you can read online Jay Godse [Jay Godse] - Ruby Data Processing: Using Map, Reduce, and Select full text of the book (entire story) in english for free. Download pdf and epub, get meaning, cover and reviews about this ebook. year: 2018, publisher: Apress, genre: Computer. Description of the work, (preface) as well as reviews are available. Best literature library LitArk.com created for fans of good reading and offers a wide selection of genres:

Romance novel Science fiction Adventure Detective Science History Home and family Prose Art Politics Computer Non-fiction Religion Business Children Humor

Choose a favorite category and find really read worthwhile books. Enjoy immersion in the world of imagination, feel the emotions of the characters or learn something new for yourself, make an fascinating discovery.

Jay Godse [Jay Godse] Ruby Data Processing: Using Map, Reduce, and Select
  • Book:
    Ruby Data Processing: Using Map, Reduce, and Select
  • Author:
  • Publisher:
    Apress
  • Genre:
  • Year:
    2018
  • Rating:
    4 / 5
  • Favourites:
    Add to favourites
  • Your mark:
    • 80
    • 1
    • 2
    • 3
    • 4
    • 5

Ruby Data Processing: Using Map, Reduce, and Select: summary, description and annotation

We offer to read an annotation, description, summary or preface (depends on what the author of the book "Ruby Data Processing: Using Map, Reduce, and Select" wrote himself). If you haven't found the necessary information about the book — write in the comments, we will try to find it.

Gain the basics of Rubys map, reduce, and select functions and discover how to use them to solve data-processing problems. This compact hands-on book explains how you can encode certain complex programs in 10 lines of Ruby code, an astonishingly small number. You will walk through problems and solutions which are effective because they use map, reduce, and select. As you read Ruby Data Processing, type in the code, run the code, and ponder the results. Tweak the code to test the code and see how the results change.
After reading this book, you will have a deeper understanding of how to break data-processing problems into processing stages, each of which is understandable, debuggable, and composable, and how to combine the stages to solve your data-processing problem. As a result, your Ruby coding will become more efficient and your programs will be more elegant and robust.
What You Will Learn
  • Discover Ruby data processing and how to do it using the map, reduce, and select functions
  • Develop complex solutions including debugging, randomizing, sorting, grouping, and more
  • Reverse engineer complex data-processing solutions

Who This Book Is For
Those who have at least some prior experience programming in Ruby and who have a background and interest in data analysis and processing using Ruby.

Jay Godse [Jay Godse]: author's other books


Who wrote Ruby Data Processing: Using Map, Reduce, and Select? Find out the surname, the name of the author of the book and a list of all author's works by series.

Ruby Data Processing: Using Map, Reduce, and Select — read online for free the complete book (whole text) full work

Below is the text of the book, divided by pages. System saving the place of the last page read, allows you to conveniently read the book "Ruby Data Processing: Using Map, Reduce, and Select" online for free, without having to search again every time where you left off. Put a bookmark, and you can go to the page where you finished reading at any time.

Light

Font size:

Reset

Interval:

Bookmark:

Make
Jay Godse 2018
Jay Godse Ruby Data Processing
1. Basic Ruby
Jay Godse 1
(1)
Kanata, Ontario, Canada
This section will acquaint or refresh you with basic ways to use the Ruby command line, as well as some relevant Ruby coding.
If you are comfortable programming in Ruby and understand the Ruby Enumerable Library reasonably well, you can skip this section.
The Command Line
After you install Ruby, you can fire up the interactive command line in Windows, Linux, or Mac OSX. Im using Windows.
C:\> irb
irb(main):001:0>
For brevity, I wont write the full irb prompt every time.
You can execute Ruby statements line by line. The value returned by each expression is preceded by .
irb> a = 4
=> 4
irb> a
=> 4
irb> a + 7
=> 11
You can choose to put multiple statements on one line, separated by a semicolon.
irb> list = ["one", "two","three"];1
=>1
irb> list
=>["one", "two", "three"]
You can also have a statement that spans multiple lines.
irb> [2,3,4,5].each do |n|
irb> if n%2==0
irb> puts "even"
irb> else
irb> puts "odd"
irb> end
irb> end
=> "even"
=> "odd"
=> "even"
=> "odd"
You can put the code into a file called sample.rb , located in the same directory or folder from which you ran irb .
1 [2,3,4,5].each do |n|
2 if n%2 == 0
3 puts "even"
4 else
5 puts "odd"
6 end
7 end
Then, with irb :
irb> load "sample.rb"
irb> end
=> "even"
=> "odd"
=> "even"
=> "odd"
irb>
You could also copy the code block from your text editor and paste it directly into your command line and get the same result, as long as you use only spaces for indentation. (Using tabs for indentation will work fine if you load the file from the command prompt, but if you paste tabs directly into irb , it will generate errors).
You can either type the code samples from this book into irb directly or type them into a text editor and then load the file as just shown.
Object Scope
When you are in a Ruby program, the general method of executing a method f on an object obj is as follows:
obj.f
That is true whether you are in a Ruby program or the command line. When code is in the main program file, or in the irb command-line interpreter, there is an implied context for many functions, such as puts . That is why you can do this:
puts "Hello world"
You dont need to specify a class to qualify puts , because puts is a method of the underlying context object.
String
Strings are basic constructs in all languages. Lets look at a few basic operations used in this book. Try them out on the irb command line for yourself.
length or size
  • This yields the size of the string.
downcase
  • This converts all letters to lowercase.
upcase
  • This converts all letters to uppercase.
capitalize
  • This capitalizes the first letter of a string.
split()
  • This searches a substring for the argument string and splits the string into a array comprising substrings on both sides of the split argument, while the substring of the split argument is discarded. If there are no matches, an array is returned with the whole string:
    irb> base_string = "abc def ghi"
    irb> base_string.split(" ")
    => ["abc","def","ghi"]
    irb> base_string.split(" ")
    => ["abc def","ghi"]
    irb> base_string.split(" d")
    => ["abc","ef ghi"]
    irb> base_string.split("efghi")
    => ["abc def ghi"]
join()
  • This joins each element of an array of strings with the string in the join argument as the separator.
    irb> stringlist = ["This", "is", "a", "sentence"]
    irb> stringlist.join(" ")
    => "This is a sentence"
    irb> stringlist.join(",")
    => "This,is,a,sentence"
    irb> stringlist.join(" A SPACE ")
    => "This A SPACE is A SPACE a A SPACE sentence "
string interpolation
  • This lets you define a string template with parameters. The string #{} gives you a place to put a variable.
    irb> first = "Jack"; last = "Black"
    irb> full_name = " #{ first } #{ last } "
    => "Jack Black"
  • This is especially useful for iterating over a list:
    irb> smith_brothers = ["Terry", "Jerry", "Harry"]
    irb> smith_brothers.each{|brother| puts " #{ brother } Smith"}
    Terry Smith
    Jerry Smith
    Harry Smith
    => ["Terry", "Jerry", "Harry"]
  • C/C++ programmers will recognize string interpolation as being similar to the sprintf function in the C standard library.
Array
Arrays in Ruby are like arrays in other languages. They are a collection of things indexed by a whole number (e.g., 0,1,2,). In Ruby, an array can contain any Ruby object at an index. Array indices in Ruby start at .
Arrays implement the Ruby Enumerable interface, so they will have key methods such as each , map , reduce , select , and others.
Special Methods
compact()
  • This method on an array gets rid of nil members. For example:
    irb> [1, nil ,2, nil , nil ,3, nil ,[]].compact
    => [1,2,3,[]]
flatten()
  • This method gets rid of inner arrays to an arbitrary depth. It is often useful when dealing with nested map and reduce statements. For example:
    irb> [[1,[2,3]],4,[5,6]].flatten
    => [1,2,3,4,5,6]
push()
  • This method pushes an element onto the end of an array and returns a new array. For example:
    irb> [1,2,3,4,5].push(666)
    => [1,2,3,4,5,666]
pop
  • This method removes the last element of an array and returns that element and returns a new array. For example:
    irb> the_array = [1,2,3,4,5]
    irb> tail = the_array.pop
    irb> tail
    => 5
    irb> the_array
    => [1, 2, 3, 4]
unshift()
  • This method pushes an element onto the beginning of an array and returns a new array. For example:
    irb> the_array = [1,2,3,4,5]
    irb> the_array.unshift(666)
    => [666, 1, 2, 3, 4, 5]
shift
  • This method removes the first element of an array and returns that element and modifies the old array. For example:
    irb> the_array = [1,2,3,4,5]
    irb> head = the_array.shift
    irb> head
    => 1
    irb> the_array
    => [2, 3, 4, 5]
Hash
Another term for hash is an associative array, or even a dictionary, Hashes are indexed by a key object, and there is a value (another object) for each key object.
Next page
Light

Font size:

Reset

Interval:

Bookmark:

Make

Similar books «Ruby Data Processing: Using Map, Reduce, and Select»

Look at similar books to Ruby Data Processing: Using Map, Reduce, and Select. We have selected literature similar in name and meaning in the hope of providing readers with more options to find new, interesting, not yet read works.


Reviews about «Ruby Data Processing: Using Map, Reduce, and Select»

Discussion, reviews of the book Ruby Data Processing: Using Map, Reduce, and Select and just readers' own opinions. Leave your comments, write what you think about the work, its meaning or the main characters. Specify what exactly you liked and what you didn't like, and why you think so.