Found 26504 Articles for Server Side Programming

How to stop unwanted UIButton animation on title change?

Nitin Aggarwal
Updated on 27-Mar-2023 15:29:57

870 Views

In iOS applications, you will often need to customize the button according to your requirements. When you add a button to the parent view, the button title is animated by default. But if you want to stop that default animation, you can use the custom button in UIKit. We will first create a situation where you can see this problem. Here is the basic setup. Initially, we will add a register button to the parent view with basic customization. We will add the constraints programmatically to the button to set the button's position. Step 1 − Create a button ... Read More

Haskell Program to Find Sum of N Numbers Using Recursion

Akhil Sharma
Updated on 27-Mar-2023 11:44:50

995 Views

In Haskell, we can find Sum of N Numbers by using recursion, tail-recursion and fold-recursion. In the first example we are going to use base case, (sum_n [] = 0) and recursive case, (sum_n (x:xs) = x + sum_n xs)) and in second example, we are going to use, tail-recursion. And in the third example, we are going to use (sumOfN''' xs = foldr (+) 0 xs) function. Algorithm Step 1 − The recursive sum_n function is defined as, For example 1 − sum_n [] = 0 sum_n (x:xs) = x + sum_n xs. ... Read More

Haskell Program to Find the Product of Two Numbers Using Recursion

Akhil Sharma
Updated on 27-Mar-2023 11:43:58

631 Views

In Haskell, we can find the Product of Two Numbers by using recursion along with recursive repeated addition. In the first example we are going to use (product' x y | y == 0 = 0 | y == 1 = x | otherwise = x + product' x (y-1)) function. And in the second example, we are going to use recursive repeated addition. Algorithm Step 1 − The recursive product’ function is defined as, For example 1 and 2 − product' x y | y == 0 = 0 ... Read More

Haskell Program to Find Sum of Digits of a Number using Recursion

Akhil Sharma
Updated on 27-Mar-2023 11:43:33

665 Views

In Haskell, we can find Sum of Digits of a Number by using recursion along with mod, div and other helper functions. getCurrentTime and NominalDiffTime function. In the first example we are going to use (sumOfDigits n | n < 10 = n | otherwise = (n `mod` 10) + sumOfDigits (n `div` 10)) function. And in the second example, we are going to use helper function. Algorithm Step 1 − The recursive sumOfDigits function is defined as, For example 1 − sumOfDigits n | n < 10 = n ... Read More

Haskell Program to Calculate the Execution Time of Methods

Akhil Sharma
Updated on 27-Mar-2023 11:42:53

1K+ Views

In Haskell, we can use getCurrentTime and NominalDiffTime functions to calculate the Execution Time of Methods. In the first example we are going to use (startTime

Haskell Program to calculate the power using Recursion

Akhil Sharma
Updated on 27-Mar-2023 11:42:11

866 Views

In Haskell, we can calculate the power by using recursion along with cases and also by using tail-recursion. In the first example we are going to use recursion along with base case, (power _ 0 = 1) and recursive case, (power x y = x * power x (y-1)). In the second example, we are going to use recursive cases as (power' x y | y == 0 = 1| otherwise = x * power' x (y-1)) and in third example, we are going to use tail-recursion. Algorithm Step 1 − The user defined recursive power function is defined ... Read More

Haskell Program to Reverse a Sentence Using Recursion

Akhil Sharma
Updated on 27-Mar-2023 11:39:48

804 Views

In Haskell, we can reverse a Sentence by using recursion along with concatenation and also by using list comprehension. In the first example we are going to use recursion along with base and recursive case and in the second example, we are going to use concatenation as ((last sentence) : reverseSentence (init sentence)) and in third example, we are going to use list comprehension as, reverseSentence s = [s !! i | i String reverseSentence [] = [] reverseSentence sentence = (last sentence) : reverseSentence (init sentence) main :: IO () main = do let ... Read More

Haskell Program to Find G.C.D Using Recursion

Akhil Sharma
Updated on 27-Mar-2023 11:32:34

193 Views

In Haskell, we can find G.C.D by using recursion and also by using recursive case statements. In the first example we are going to use recursion along with base and recursive case and in the second example, we are going to use (case (x, y) of) statement. Algorithm Step 1 − The user defined recursive gcd’ function is defined as, For example 1 − gcd' x y | y == 0 = x | otherwise = gcd' y (x `mod` y). For example 2 − ... Read More

Haskell Program to Find Factorial of a Number Using Recursion

Akhil Sharma
Updated on 27-Mar-2023 11:31:56

2K+ Views

In Haskell, we Find Factorial of a Number Using Recursion by using recursion along with foldl and product function. In the first example we are going to use recursion along with base and recursive case and in the second example, we are going to use factorial n = foldl (*) 1 [1..n] function and third example, we are going to use factorial n = product [1..n] function. Algorithm Step 1 − The user defined recursive factorial function is defined as, For example 1 & 2 − factorial 0 = 1 factorial n = n * factorial ... Read More

Haskell Program to Find the Sum of Natural Numbers using Recursion

Akhil Sharma
Updated on 27-Mar-2023 11:30:58

291 Views

In Haskell, we Find the Sum of Natural Numbers by using recursion and tail-recursion. In the first example we are going to use recursion along with base and recursive case and in the second example, we are going to use sumNat function and third example, we are going to use user-defined tail-recursive function. Algorithm Step 1 − The user defined recursive sumOfNaturalNumbers function is defined as, For example 1, 2 & 3 sumOfNaturalNumbers 0 = 0 sumOfNaturalNumbers n = n + sumOfNaturalNumbers (n - 1). For example 4 sumNat' 0 acc = acc ... Read More

Advertisements