ARRAY RUBY. PENDAHULUAN Ruby's arrays are untyped and mutable. The elements of an array need not all be of the same class, and they can be changed at.

Slides:



Advertisements
Presentasi serupa
Linked List dan Double Linked List
Advertisements

Gambar Proyeksi Orthografi
STRUKTUR DATA (4) Array Stack(Tumpukkan) dan Queue (Antrian)
Pemrograman Berbasis Obyek
Relation
STRUCTURAL CONTROL STATEMENT  If  If…..else….  If ….elseif…else.
Pengantar Pemrograman
Dasar Pemrograman Java Pertemuan 2 Pemrograman Berbasis Obyek Oleh Tita Karlita.
Validitas & Reliabilitas
INFINITIVE CLAUSES Infinitive clause is TO (untuk) that is put before original verb, if the words are preceded by: The other verbs To be Examples: Saya.
Algoritma dan Struktur Data
1 DATA STRUCTURE “ STACK” SHINTA P STMIK MDP APRIL 2011.
Class and Object Introduction Specifying a Class Defining Member Function A C++ Program with Class Nesting of Member Functions Private Member Functions.
BLACK BOX TESTING.
Presented By : Group 2. A solution of an equation in two variables of the form. Ax + By = C and Ax + By + C = 0 A and B are not both zero, is an ordered.
Propagasi Gelombang Pertemuan 8 Matakuliah: H0122 / Dasar Telekomunikasi Tahun: 2008.
Research Design (Cont). Jenis Perancangan Riset Jenis perancangan mana yg akan digunakan ? Peneliti perlu memikirkan tentang apa yang mereka inginkan.
STRUKTUR DATA (4) array stack dan queue
Menjadi Orang yang Percaya Diri Pertemuan 9 Matakuliah: CB 1 Tahun:
Dasar Pemrograman Java Pertemuan 2 Pemrograman Berbasis Obyek.
Menulis Kolom  Kolom adalah opini atau artikel. Tidak seperti editorial, kolom memiliki byline.  Kolom Biasanya ditulis reguler. Biasanya mingguan atau.
METHOD, ARRAY DAN STRING
1 Pertemuan 12 Pengkodean & Implementasi Matakuliah: T0234 / Sistem Informasi Geografis Tahun: 2005 Versi: 01/revisi 1.
Algoritma dan Struktur Data
BAB 6 KOMBINATORIAL DAN PELUANG DISKRIT. KOMBINATORIAL (COMBINATORIC) : ADALAH CABANG MATEMATIKA YANG MEMPELAJARI PENGATURAN OBJEK- OBJEK. ADALAH CABANG.
PERTEMUAN KE-6 UNIFIED MODELLING LANGUAGE (UML) (Part 2)
1 Pertemuan 23 Sequence Diagram Matakuliah: M0086/Analisis dan Perancangan Sistem Informasi Tahun: 2005 Versi: 5.
1 Pertemuan 13 Algoritma Pergantian Page Matakuliah: T0316/sistem Operasi Tahun: 2005 Versi/Revisi: 5.
Bayu Priyambadha, S.Kom.  Classes, which are the "blueprints" for an object and are the actual code that defines the properties and methods.  Objects,
Lecture 5 Stack Eka, Erick, Reddy © Sekolah Tinggi Teknik Surabaya 1.
9.3 Geometric Sequences and Series. Objective To find specified terms and the common ratio in a geometric sequence. To find the partial sum of a geometric.
Binary Search Tree. Sebuah node di Binary Search Tree memiliki path yang unik dari root menurut aturan ordering – Sebuah Node, mempunyai subtree kiri.
Visual Basic for Aplications in powerpoint. What is Visual Basic for Aplications? Visual Basic for Applications (VBA) is a very powerful objectoriented.
Mencari dan Menyelamatkan Yang Terhilang
DISTRIBUSI BINOMIAL.
KOMUNIKASI DATA Materi Pertemuan 3.
Buy Famvir Online Canada
Induksi Matematika.
Pertemuan 23 Sequence Diagram
PHP Array & Form.
Struktur Data Stack Oleh Lutfi Budi Ilmawan
Dynamic Array and Linked List
LIMIT FUNGSI LIMIT FUNGSI ALJABAR.
Konsep pemrograman LOOP
PENDIDIKAN KARAKTER DALAM MATA PELAJARAN FISIKA SMA
Pengujian Hipotesis (I) Pertemuan 11
Pertemuan 3 Variabel/Dinamik Pointer
DISTRIBUSI BINOMIAL.
BY EKA ANDRIANI NOVALIA RIZKANISA VELA DESTINA
Pemrograman Berorientasi Objek
Significantly Significant
REAL NUMBERS EKSPONENT NUMBERS.
Pertemuan 4 CLASS DIAGRAM.
ELASTIC PROPERTIS OF MATERIAL
Algoritma dan Struktur Data
Algoritma dan Struktur Data
How You Can Make Your Fleet Insurance London Claims Letter.
How Can I Be A Driver of The Month as I Am Working for Uber?
Things You Need to Know Before Running on the Beach.
Algoritma & Pemrograman 1 Achmad Fitro The Power of PowerPoint – thepopp.com Chapter 4.
 Zoho Mail offers easy options to migrate data from G Suite or Gmail accounts. All s, contacts, and calendar or other important data can be imported.
If you are an user, then you know how spam affects your account. In this article, we tell you how you can control spam’s in your ZOHO.
CALL PC EXPERT How to Remove Adware, Pop- up Ads from Web Browser.
ROCKETMAIL SIGNUP, LOGIN AND HOW TO RAGISTER NEW ROCKETMAIL ACCOUNT In this post, we will be sharing tips on Rocket mail signup and how to create an account.
Unit: 8 The simple past tense Meaning & Use Form (structure) Exercise.
Website: Website Technologies.
Importance of Web Development Frameworks Frameworks, no doubt have become a crucial aspect of web development. In fact, many find the entire development.
Draw a picture that shows where the knife, fork, spoon, and napkin are placed in a table setting.
WINTER Template COLOUR CARD 01 Template. PowerPoint chart object 02.
By Group 5. Once upon a time a lion was roaming in the jungle in search of a prey. Luckily, he saw a rabbit sleeping fast under a tree. He was delighted.
Transcript presentasi:

ARRAY RUBY

PENDAHULUAN Ruby's arrays are untyped and mutable. The elements of an array need not all be of the same class, and they can be changed at any time. Furthermore, arrays are dynamically resizeable; you can append elements to them and they grow as needed. If you assign a value to an element beyond the end of the array, the array is automatically extended with nil elements. (It is an error, however, to assign a value to an element before the beginning of an array.)

DEKLARASI nama_variable=[nil]; atau nama_variabel=Array.new(ukuran, obj); Contoh: A=[nil]; B=Array.new(10,nil);

ARRAY LITERAL # An array that holds three Fixnum objects [1, 2, 3] # An array of two ranges; trailing commas are allowed [ , 0..10,] # An array of nested arrays [[1,2],[3,4],[5]] # Array elements can be arbitrary expressions [x+y, x-y, x*y] # The empty array has size 0 []

SPECIAL SYNTAKS words = %w[this is a test] # Same as: ['this', 'is', 'a', 'test'] open = %w| ( [ { < | # Same as: ['(', '[', '{', '<'] white = %w(\s \t \r \n) # Same as: ["\s", "\t", "\r", "\n"]

MENGAKSES ISI ARRAY a = [0, 1, 4, 9, 16] # Array holds the squares of the indexes a[0] # First element is 0 a[-1] # Last element is 16 a[-2] # Second to last element is 9 a[a.size-1] # Another way to query the last element a[-a.size] # Another way to query the first element a[8] # Querying beyond the end returns nil a[-8] # Querying before the start returns nil, too

CONTOH MENGISI ARRAY 1 DIMENSI YANG MEMILIKI 5 ELEMEN: A=[nil], temp=0, i=0; for i in 1..5 # loop untuk mengisi array printf ("Isi elemen array A ke-"+i.to_s+" : "); A[i]=gets.to_i; #mengubah semua input menjadi nilai integer end for i in 1..5 #loop untuk menampilkan isi array printf ("Isi elemen array A ke-"+i.to_s+" : "+A[i].to_s+"\n"); end

ARRAY 2D Deklarasi: nama_variabel=Array.new(ukuran, obj); Contoh: Angka=Array.new(3,Array.new(5,nil)); kolom 0kolom 1kolom 2 Kolom 3 kolom 4 baris 0 [0][0][0][1][0][2][0][3][0][4] baris 1 [1][0][1][1][1][2][1][3][1][4] baris 2 [2][0][2][1][2][2][2][3][2][4]

ARRAY ND # membentuk struktur data 3 dimensi. Sumbu x, y, z Ruang=Array.new(5,Array.New(5,Array.new(5,nil)); # membentuk struktur data 6 dimensi. # Sulit sekali memvisualisasikannya frase= Array.new(3,Array.New(3,Array.new(3, Array.new(5,Array.New(5,Array.new(7,nil))))

LATIHAN Cari nilai statistik dari data array number Max Min Buat program untuk mengisi dan menampilkan array 2D (gunakan perulangan)

TUGAS ARRAY+FUNGSI MOD 6 1.Buatlah program untuk menghitung fungsi statistik (input berupa array yg sudah terinisialisasi bisa pada saat design time maupun otomatis) yang mempunyai fungsi untuk: 1.Rata-rata 2.Menghitung modus (nilai yang paling sering muncul).

TUGAS 2. Buat programuntuk operasi matriks 2D yang berisi angka. 1.penjumlahan 2.pengurangan 3.perkalian titik 4.perkalian silang