Tail Recursive Function in Scala PRO

If the last action a function performs is calling to itself then it is a tail recursive function. When a tail recursive function is executed the computer doesn’t need to keep the memory stack frames. It can use one frame only. Using the @tailrec annotation we can instruct the computer to use one frame only […]

The Returned Type of Recursive Function in Scala PRO

When you define a recursive function you must specify the type of the returned value. If you don’t do it the compilation fails. object Program { def main(args: Array[String]):Unit = { println(factorial(4)) } def factorial(num:Int):Int = if (num==0) 1 else num*factorial(num-1) } The following video clip explains that.

The sscanf Function in PHP PRO

This function allows us to extract values from a string that applies a specific pattern. Each place holder (e.g. %s) refers a specific value in our string. Each value that matches a specific place holder is assigned to a variable. We should pass over our variable to be assigned by the values that match the […]

The setlocale Function in PHP PRO

Calling this function we can apply a specific locale (combination of a language, a country and possible few more values) on our program. The first argument should be a constant that specifies on what do we want to apply the new locale (e.g. LC_NUMERIC will apply our locale on the decimal separator). The second argument […]

The Android findViewById Function PRO

Most Android developers are fairly well familiar with the findViewById function our activity inherits from the Activity class. This function receives the ID number of a specific View resource the activity user interface includes. If you ever try to call that function before calling the setContentView function (our activity inherits from the Activity class) then […]

The PHP 5.2 filter_var Function PRO

PHP 5.2 adds the filter_var function. It is an important function that assists with validating the user input. <?php $email_address_dirty = “haim.michael@gmail.com”; if(filter_var($email_address_dirty,FILTER_VALIDATE_EMAIL)) { $email_address_clean = $email_address_dirty; } echo $email_address_clean; ?> The following video clip shows the execution of this code sample and explains it.

The __get & __set Magical Functions in PHP PRO

Using these two functions we can dynamically add new variables, that weren’t defined in the class, to objects in our program. <? class Bongo { var $vec; function __construct() { $this->vec = array(); } function __get($str) { return $this->vec[$str]; } function __set($var_name,$var_value) { $this->vec[$var_name] = $var_value; } } $ob = new Bongo(); $ob->name=”balaboa”; $ob->id=12123123; echo […]

Functions in Python PRO

I have just completed to update the functions topic in my Python Fundamentals course. You can find its community version available for free personal usage at www.abelski.org. The slides are available for free download. The professional version is available at www.abelski.com. You can find below the new video clips I have just completed to create […]

Conditional Functions in Python PRO

Python allows us to condition the definition of a function. Since the function is defined during the execution of the code itself we can use a conditional statement in order to define the function that fits most. recursive = True if recurcive: def factorial(n): print(“within recursive factorial”) if n==0: return 1 else: return factorial(n-1)*n else: […]

Functions in Scala PRO

I have recently developed a collection of video clips that explain various topics related to defining and using functions in the Scala programming language. These video clips, as well as many others, are available as part of the ‘Scala Fundamentals’ course, available for free personal and academic usage at www.abelski.com.

Skip to content Update cookies preferences