Scala, Java 50 programming questions

⚠️ The correctness of the solution is not guaranteed! 1. There are a pair of rabbits. From the third month after birth, a pair of rabbits are born every month. The rabbits grow to another pair of rabbits every month after the third month. If none of the rabbits dies, what is the total number of rabbits per month? def main(args: Array[Strin ...

Posted by GreyFilm on Mon, 06 Dec 2021 09:13:55 -0800

Basic Summary of Scala

1. Basic concepts Basic concepts Class: The abstraction of objects of the same type, such as people, planets, cars, etc.Object: A specific instance of a class containing properties and methods such as a person, a planet, a vehicle, and so onAttributes: Used to describe certain characteristics of an object, such as a person's age, name, etc. ...

Posted by balacay on Sat, 04 Dec 2021 09:58:51 -0800

Summary of advanced use of scala

1. Matching pattern Summary Similar to switch...case in java, but much more powerful and flexible.The goal is to solve the matching and processing problems when a pattern (value is also one of the patterns) is met.Instructions A pattern match consists of a series of alternatives, each starting with the keyword case. Each alternative cont ...

Posted by Dvector on Sat, 04 Dec 2021 09:38:05 -0800

Scala classes and singletons

1. Basic operation of class 1.1. Definition of class Class or type is the abstraction of an objective class of things. A class keyword is used to describe the properties, behaviors, etc. of this kind of things in this class. In other words, a kind of things described in computer language, that is, classes, are identified by the keyword class ...

Posted by sethadam1 on Thu, 02 Dec 2021 18:04:58 -0800

Scala --- option type and partial function, exception handling, regular expression

1. Pattern matching Scala has a very powerful pattern matching mechanism and is widely used, such as: Judge fixed valueType queryGet data quickly 1.1 simple pattern matching A pattern matching contains a series of alternatives, each of which starts with the keyword case. Each alternative contains a pattern and one or more expressions. The a ...

Posted by KingPhilip on Tue, 30 Nov 2021 23:38:39 -0800

scala -- Set, Map, iterator, flattening, filtering, sorting, grouping, aggregation

4. Set set Set (also known as: Set) represents a set without duplicate elements. Features: unique, disordered The only meaning is that the elements in the Set are unique and there are no duplicate elementsUnordered means that the order in which the elements in the Set are added and taken out is inconsistent Format I: Create an empty immutabl ...

Posted by wee493 on Mon, 29 Nov 2021 15:14:24 -0800

Spin HDL - 09 - timing logic

Registers Creating registers with SpinalHDL is very different from creating registers with VHDL or Verilog. In SpinalHDL, there is no process / always blocking. Registers are clearly defined in the declaration. This is very different from the traditional event driven HDL: You can allocate registers and connections in the same range, which me ...

Posted by Terminator on Mon, 29 Nov 2021 03:05:48 -0800

Scala -- definition of classes and objects + use of associated objects

1. Classes and objects Scala is a functional object-oriented language. It also supports the idea of object-oriented programming, and also has the concept of class and object. We can still develop object-oriented applications based on Scala. 1.1 related concepts What is object oriented? Object oriented is a programming idea, It is based on p ...

Posted by knsito on Sun, 28 Nov 2021 19:14:00 -0800

Scala -- the use of trait trait

1. Introduction to characteristics 1.1 general Sometimes, we will encounter some specific needs, that is, to strengthen the functions of some classes (or objects) without affecting the current inheritance system. For example, there are monkeys and elephants. They all have names, ages and eating functions, but some monkeys are trained by the c ...

Posted by Trekx on Sun, 28 Nov 2021 17:04:54 -0800

Spark SQL knowledge points and actual combat

Pay attention to the official account: big data technology, reply to "information" and receive 1000G information. This article started on my personal blog: Spark SQL knowledge points and actual combat Spark SQL overview 1. What is Spark SQL Spark SQL is a spark module used by spark for structured data processing. Unlike the basi ...

Posted by lovasco on Fri, 26 Nov 2021 16:41:48 -0800