code-rag-bench/online-tutorials huggingface dataset:
How to add a day to datetime field in MySQL query?

To add a day to datetime field, use the DATE_ADD() function. The syntax is as follows −
SELECT DATE_ADD(yourColumnName,interval yourIntegerValue day) as anyVariableName from yourTableName;
Let us first create a table −
mysql> create table AddOneDayDemo
−> (
   −> YourDay datetime
−> );
Query OK, 0 rows affected (1.37 sec)
Insert current date with the help of curdate() and after that use date_add() function to add a day.
To insert a day into the table, the following is the query −
mysql> insert into AddOneDayDemo values(curdate());
Query OK, 1 row affected (0.17 sec)
Display records with the help of select statement. The query is as follows −
mysql> select *from AddOneDayDemo;
The following is the record with current date −
| YourDay             |
+---------------------+
| 2018-11-27 00:00:00 |
+---------------------+
1 row in set (0.00 sec)
The query to add a day to current date is as follows −
mysql> select date_add(YourDay,interval 1 day) as yourDayafteraddingoneday from AddOneDayDemo;
The following is the output -
+--------------------------+
| yourDayafteraddingoneday |
+--------------------------+
| 2018-11-28 00:00:00      |  
+--------------------------+
1 row in set (0.00 sec)
The above output displays a date that is an addition to the current date.
Clear text from textarea with selenium.

We can clear text from a text area with Selenium. We shall use the clear method to remove the content from a text area or an edit box. First we shall identify the text area with the help of any locator.
A text area is identified with textarea tagname in the html code. Let us input some text inside the below text area, then clear the text.
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
public class TextAreaClear{
   public static void main(String[] args) {
      System.setProperty("webdriver.chrome.driver","C:\\Users\\ghs6kor\\Desktop\\Java\\chromedriver.exe");
      WebDriver driver = new ChromeDriver();
      driver.get("http://www.uitestpractice.com/Students/Form");
      // identify element
      WebElement m = driver.findElement(By.id("comment"));
      // enter text
      m.sendKeys("Selenium");
      // obtain value entered in text area
      System.out.println("Value entered: " + m.getAttribute("value"));
      // clear text area
      m.clear();
      // obtain value entered in text area after clear applied
      System.out.println("Value after clear(): " + m.getAttribute("value"));
      driver.quit();
   }
}
How to calculate greatest common divisor of two or more numbers/arrays in JavaScript ? - GeeksforGeeks

22 Apr, 2021
Given two or more numbers/array of numbers and the task is to find the GCD of the given numbers/array elements in JavaScript.
Examples:
Input  : arr[] = {1, 2, 3}
Output : 1

Input  : arr[] = {2, 4, 6, 8}
Output : 2
The GCD of three or more numbers equals the product of the prime factors common to all the numbers, but it can also be calculated by repeatedly taking the GCD of pairs of numbers.
gcd(a, b, c) = gcd(a, gcd(b, c))
            = gcd(gcd(a, b), c)
            = gcd(gcd(a, c), b)
For an array of elements, we do the following. We will also check for the result if the result at any step becomes 1 we will just return 1 as gcd(1, x) = 1.
result = arr[0]
For i = 1 to n-1
  result = GCD(result, arr[i])
Below is the implementation of the above approach.
Code Example:
Javascript
<script>      // Function to return gcd of a and b    function gcd(a, b) {        if (a == 0)            return b;        return gcd(b % a, a);    }      // Function to find gcd of array    // of numbers    function findGCD(arr, n) {        let result = arr[0];        for (let i = 1; i < n; i++) {            result = gcd(arr[i], result);              if (result == 1) {                return 1;            }        }        return result;    }      // Driver code    let arr = [2, 4, 6, 8, 16];    let n = arr.length;    document.write(findGCD(arr, n) + "<br>");  </script>
Output: 
2
Time Complexity: O(N * log(M)), where M is the smallest element of the array and N is the length of the array.
javascript-math
JavaScript-Methods
JavaScript-Questions
Picked
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Convert a string to an integer in JavaScript
Difference between var, let and const keywords in JavaScript
How to calculate the number of days between two dates in javascript?
Differences between Functional Components and Class Components in React
How to append HTML code to a div using JavaScript ?
Roadmap to Become a Web Developer in 2022
Installation of Node.js on Linux
How to fetch data from an API in ReactJS ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Convert a string to an integer in JavaScript
<mat-grid-list> in Angular Material - GeeksforGeeks

24 Sep, 2021
Angular Material is a UI component library that is developed by the Angular team to build design components for desktop and mobile web applications. In order to install it, we need to have angular installed in our project, once you have it you can enter the below command and can download it. mat-grid-list tag is used for styling the content in grids form.
Installation syntax:
ng add @angular/material
Approach:
First, install the angular material using the above-mentioned command.
After completing the installation, Import ‘MatGridListModule’ from ‘@angular/material/grid-list’ in the app.module.ts file.
Then use <mat-grid-list> tag to group all the items inside this group tag.
Inside the <mat-grid-list> tag we need to use <mat-grid-tile tag for every item.
We also have properties like cols and rowHeight which we can use for styling. cols property is used to display number of grids in a row.
Once done with the above steps then serve or start the project.
Code Implementation:
app.module.ts
import { CommonModule } from '@angular/common'; import { NgModule } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { MatGridListModule } from '@angular/material';     import { AppComponent } from './example.component';     @NgModule({   declarations: [AppComponent],   exports: [AppComponent],   imports: [     CommonModule,     FormsModule,     MatGridListModule    ], }) export class AppModule {}
app.component.html
<mat-grid-list cols="3" rowHeight="2:1">      <mat-grid-tile>First Grid</mat-grid-tile>  <mat-grid-tile>Second Grid</mat-grid-tile>  <mat-grid-tile>Third Grid</mat-grid-tile>  <mat-grid-tile>Fourth Grid</mat-grid-tile>  <mat-grid-tile>Fifth Grid</mat-grid-tile>  <mat-grid-tile>Sixth Frid</mat-grid-tile>  </mat-grid-list>
app.component.scss :
mat-grid-tile {
  background: lightsalmon;
}
Output:
 
 
simmytarika5
Angular-material
Picked
AngularJS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Angular PrimeNG Dropdown Component
Angular PrimeNG Calendar Component
Angular PrimeNG Messages Component
Angular 10 (blur) Event
How to make a Bootstrap Modal Popup in Angular 9/8 ?
Remove elements from a JavaScript Array
Installation of Node.js on Linux
Convert a string to an integer in JavaScript
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
Python | Convert list of strings to list of tuples - GeeksforGeeks

29 Apr, 2019
Sometimes we deal with different types of data types and we require to inter convert from one data type to another and hence inter conversion always a useful tool to have knowledge about. The interconversion from tuples to other formats have been discussed earlier. This article deals with the converse case. Let’s discuss certain ways in which this can be done.
Method #1 : Using map() + split() + tuple()
This task can be achieved using the combination of these functions. The map function can be used to link the logic to each string, split function is used to split the inner contents of list to different tuple attributes and tuple function performs the task of forming a tuple.
# Python3 code to demonstrate# convert list of strings to list of tuples# Using map() + split() + tuple()  # initializing listtest_list = ['4, 1', '3, 2', '5, 3']  # printing original listprint("The original list : " + str(test_list))  # using map() + split() + tuple()# convert list of strings to list of tuplesres = [tuple(map(int, sub.split(', '))) for sub in test_list]   # print resultprint("The list after conversion to tuple list : " + str(res))
The original list : ['4, 1', '3, 2', '5, 3']
The list after conversion to tuple list : [(4, 1), (3, 2), (5, 3)]

 
Method #2 : Using map() + evalThis is the most elegant way to perform this particular task. Where map function is used to extend the function logic to the whole list eval function internally performs interconversions and splitting.
# Python3 code to demonstrate# convert list of strings to list of tuples# Using map() + eval  # initializing listtest_list = ['4, 1', '3, 2', '5, 3']  # printing original listprint("The original list : " + str(test_list))  # using map() + eval# convert list of strings to list of tuplesres = list(map(eval, test_list))  # print resultprint("The list after conversion to tuple list : " + str(res))
The original list : ['4, 1', '3, 2', '5, 3']
The list after conversion to tuple list : [(4, 1), (3, 2), (5, 3)]

Python list-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Python Dictionary
Enumerate() in Python
How to Install PIP on Windows ?
Different ways to create Pandas Dataframe
Python String | replace()
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Python program to check whether a number is Prime or not
How to print without newline in Python?
Undecidability - GeeksforGeeks

21 Jan, 2014
First is Emptiness for CFG; whether a CFG is empty or not, this problem is decidable.
Second is everything for CFG; whether a CFG will generate all possible strings (completeness of CFG), this problem is undecidable.
Third is Regularity for REC; whether language generated by TM is regular is undecidable.
Fourth is equivalence for regular; whether language generated by DFA and NFA are same is decidable.
Which of the following problems are decidable?
I. Whether the intersection of two regular languages is infinite
II. Whether a given context-free language is regular
III. Whether two push-down automata accept the same language
IV. Whether a given grammar is context-free
1. If A ≤p B and B is decidable then A is also decidable.
This is because if there exists a specific algorithm for solving B and we can 
also reduce A to B then we can have a solution of A as well. Hence A is decidable.

However the reverse is not true i.e. if A ≤p B and A is decidable 
then B is also decidable because A can have an algorithm existing for its correct 
solution but might be the case that B does not.

2. If A ≤p B and A is undecidable then B is also undecidable.
This is because if A is undecidable even when it can be reduced to B that simply 
reflects even B cannot provide an algorithm by which we can solve B and hence A. 
So decision problem B is also undecidable.


Option 1: P1 ≤p P3 and given P1 is decidable gives no conclusion for P3.
Option 2: P3 ≤p P2 and given P2 is undecidable gives no conclusion for P3.
Option 3: P2 ≤p P3 and given P2 is undecidable gives conclusion for P3 to be 
          undecidable.
Option 4: P3 ≤p P2’s complement and given P2 is undecidable therefore P2’s 
           complement is also undecidable gives no conclusion for P3.

Given a Turing machine M over the input alphabet Σ, any
state q of M And a word w∈Σ*, does the computation of M
on w visit the state q? 
(P1) Does a given finite state machine accept a given string
(P2) Does a given context free grammar generate an infinite 
     number of stings
A finite state machine always halts in final or non-final state.Therefore, problem P1 is decidable.
We check if the context free language generates any string of length between n and (2n – 1). If so, context free language is infinite else it is finite.Therefore, problem P2 is decidable.
 Thus, option (A) is correct.
Please comment below if you find anything wrong in the above post.
Writing code in comment? Please use ide.geeksforgeeks.org, generate link and share the link here.
Python Program for Breadth First Search or BFS for a Graph
Best Time to Buy and Sell Stock
Must Do Coding Questions for Product Based Companies
How to calculate MOVING AVERAGE in a Pandas DataFrame?
What is "network ID" and "host ID" in IP Addresses?
What is Transmission Control Protocol (TCP)?
Converting nested JSON structures to Pandas DataFrames
Bash Scripting - How to check If File Exists
Python Raise Keyword
Python OpenCV - Canny() Function
How to switch to frames in Selenium?

We can switch to frames in Selenium with the help of the following methods −
switchTo()defaultContent()This method is for switching to and fro in between frames and parent frames. The focus is shifted to the main page.
switchTo()defaultContent()
This method is for switching to and fro in between frames and parent frames. The focus is shifted to the main page.
switchTo().parentFrame()This method is used to switch the control to the parent frame of the current frame.
switchTo().parentFrame()
This method is used to switch the control to the parent frame of the current frame.
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import java.util.concurrent.TimeUnit;
public class FrameDefault {
   public static void main(String[] args) {
      System.setProperty("webdriver.chrome.driver", "C:\\Users\\ghs6kor\\Desktop\\Java\\chromedriver.exe");
      WebDriver driver = new ChromeDriver();
      String url = "url with frames";
      driver.get(url);
      driver.manage().timeouts().implicitlyWait(12, TimeUnit.SECONDS);
      //grabbing the first frame with the help of index
      driver.switchTo().frame(0);
      System.out.println("Getting the page source " + driver.getPageSource());
      // switching back to the parent web page
      driver.switchTo().defaultContent();
      driver.quit();
   }
}
C# - Jagged Arrays

A Jagged array is an array of arrays. You can declare a jagged array named scores of type int as −
int [][] scores;

Declaring an array, does not create the array in memory. To create the above array −
int[][] scores = new int[5][];
for (int i = 0; i < scores.Length; i++) {
   scores[i] = new int[4];
}
You can initialize a jagged array as −
int[][] scores = new int[2][]{new int[]{92,93,94},new int[]{85,66,87,88}};
Where, scores is an array of two arrays of integers - scores[0] is an array of 3 integers and scores[1] is an array of 4 integers.
The following example illustrates using a jagged array −
using System;

namespace ArrayApplication {
   class MyArray {
      static void Main(string[] args) {
         
         /* a jagged array of 5 array of integers*/
         int[][] a = new int[][]{new int[]{0,0},new int[]{1,2},
            new int[]{2,4},new int[]{ 3, 6 }, new int[]{ 4, 8 } };
         int i, j;
         
         /* output each array element's value */
         for (i = 0; i < 5; i++) {
            for (j = 0; j < 2; j++) {
               Console.WriteLine("a[{0}][{1}] = {2}", i, j, a[i][j]);
            }
         }
         Console.ReadKey();
      }
   }
}
When the above code is compiled and executed, it produces the following result −
a[0][0]: 0
a[0][1]: 0
a[1][0]: 1
a[1][1]: 2
a[2][0]: 2
a[2][1]: 4
a[3][0]: 3
a[3][1]: 6
a[4][0]: 4
a[4][1]: 8


    119 Lectures 
     23.5 hours 

 Raja Biswas

    37 Lectures 
     13 hours 

 Trevoir Williams

    16 Lectures 
     1 hours 

 Peter Jepson

    159 Lectures 
     21.5 hours 

 Ebenezer Ogbu

    193 Lectures 
     17 hours 

 Arnold Higuit

    24 Lectures 
     2.5 hours 

 Eric Frick
 Print
 Add Notes
 Bookmark this page
How to add +1 to existing MySQL values?

Let us see an example and create a table first.
mysql> create table Add1ToExistingValue
   -> (
   -> Value int
   -> );
Query OK, 0 rows affected (0.56 sec)
Insert some records in the table using insert command.
The query is as follows
mysql> insert into Add1ToExistingValue values(10);
Query OK, 1 row affected (0.12 sec)
mysql> insert into Add1ToExistingValue values(13);
Query OK, 1 row affected (0.15 sec)
mysql> insert into Add1ToExistingValue values(15);
Query OK, 1 row affected (0.13 sec)
mysql> insert into Add1ToExistingValue values(16);
Query OK, 1 row affected (0.14 sec)
mysql> insert into Add1ToExistingValue values(20);
Query OK, 1 row affected (0.16 sec)
mysql> insert into Add1ToExistingValue values(40);
Query OK, 1 row affected (0.15 sec)
mysql> insert into Add1ToExistingValue values(50);
Query OK, 1 row affected (0.11 sec)
mysql> insert into Add1ToExistingValue values(55);
Query OK, 1 row affected (0.17 sec)
mysql> insert into Add1ToExistingValue values(56);
Query OK, 1 row affected (0.17 sec)
Display all records from the table using select statement.
The query is as follows
mysql> select *from Add1ToExistingValue;
The following is the output
+-------+
| Value |
+-------+
| 10    |
| 13    |
| 15    |
| 16    |
| 20    |
| 40    |
| 50    |
| 55    |
| 56    |
+-------+
9 rows in set (0.00 sec)
Here is the query to add +1 to existing values
mysql> update Add1ToExistingValue set Value=Value+1 where Value >=20;
Query OK, 5 rows affected (0.08 sec)
Rows matched: 5 Changed: 5 Warnings: 0
Let us check the table records from the table using select statement.
The query is as follows
mysql> select *from Add1ToExistingValue;
The following is the output
+-------+
| Value |
+-------+
| 10    |
| 13    |
| 15    |
| 16    |
| 21    |
| 41    |
| 51    |
| 56    |
| 57    |
+-------+
9 rows in set (0.00 sec)
How to get last 4 characters from string in
C#?

Firstly, set the string −
string str = "Football and Tennis";
Now, use the substring() method to get the last 4 characters −
str.Substring(str.Length - 4);
Let us see the complete code −
 Live Demo
using System;
public class Demo {
   public static void Main() {
      string str = "Football and Tennis";
      string res = str.Substring(str.Length - 4);
      Console.WriteLine(res);
   }
}
nnis
Getting type of different data types in R Programming - typeof() Function - GeeksforGeeks

12 Jun, 2020
typeof() function in R Language is used to return the types of data used as the arguments.
Syntax: typeof(x)
Parameters:x: specified data
Example 1:
# R program to illustrate# typeof function  # Specifying "Biochemical oxygen demand"# data setx <- BODx  # Calling typeof() functiontypeof(x)
Output:
  Time demand
1    1    8.3
2    2   10.3
3    3   19.0
4    4   16.0
5    5   15.6
6    7   19.8
[1] "list"

Example 2:
# R program to illustrate# typeof function  # Calling typeof() function # over different types of data typeof(2)typeof(2.8)typeof("3")typeof("gfg")typeof(1 + 2i)
Output:
[1] "double"
[1] "double"
[1] "character"
[1] "character"
[1] "complex"

R Data-types
R Object-Function
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Replace specific values in column in R DataFrame ?
How to change Row Names of DataFrame in R ?
Filter data by multiple conditions in R using Dplyr
Change Color of Bars in Barchart using ggplot2 in R
Loops in R (for, while, repeat)
Printing Output of an R Program
How to Change Axis Scales in R Plots?
Group by function in R using Dplyr
How to Split Column Into Multiple Columns in R DataFrame?
K-Means Clustering in R Programming
How do I prevent an iOS device from going to sleep mode?

When most apps have no touches as user input for a short period, the system puts the device into a "sleep” state where the screen dims. This is done for the purposes of conserving power.
Preventing iOS Device from going to sleep is easy, navigate to your Settings → Display & Brightness → Autolock, select never.
This will never lock your screen.
If you’re developing an iOS Application and you’re required to implement this feature, you should use isidletimerdisabled provided by apple, to read more about it https://developer.apple.com/documentation/uikit/uiapplication/1623070-isidletimerdisabled
In your viewDidLoad method write the following line of code to prevent the device from going to sleep.
UIApplication.shared.isIdleTimerDisabled = true
Difference between MySQL BigInt(20) and Int(20)?

The int type takes 4 byte signed integer i.e. 32 bits ( 232 values can be stored). The BigInt type takes 8 byte signed integer i.e. 64 bits (264 values can be stored).
Let us see an example.
Creating a table with zerofill, that would add leading zeros.
mysql> create table IntandBigint20Demo
   -> (
   -> Number int(20) zerofill,
   -> Code BigInt(20) zerofill
   -> );
Query OK, 0 rows affected (0.58 sec)
After creating a table, we will insert records into the table.
mysql> insert into IntandBigint20Demo values(987,987);
Query OK, 1 row affected (0.16 sec)
Now we can display all records with the help of select statment. The query is as follows −
mysql> select *from IntandBigint20Demo;
The following is the output.
+----------------------+----------------------+
| Number               | Code                 |
+----------------------+----------------------+
| 00000000000000000987 | 00000000000000000987 |
+----------------------+----------------------+
1 row in set (0.00 sec)

Look at the sample output, in the beginning, 0 gets filled. This itself states that 20 is the width in let’s say.
Number int(20) zerofill
Get the sum of columns for duplicate records in MySQL

For this, use GROUP BY clause along with aggregate function SUM(). Let us first create a table −
mysql> create table DemoTable(
   Name varchar(100),
   Score int
);
Query OK, 0 rows affected (0.70 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('Adam',50);
Query OK, 1 row affected (0.14 sec)
mysql> insert into DemoTable values('Bob',80);
Query OK, 1 row affected (0.13 sec)
mysql> insert into DemoTable values('Adam',70);
Query OK, 1 row affected (0.14 sec)
mysql> insert into DemoTable values('Adam',10);
Query OK, 1 row affected (0.12 sec)
mysql> insert into DemoTable values('Carol',98);
Query OK, 1 row affected (0.17 sec)
mysql> insert into DemoTable values('Bob',10);
Query OK, 1 row affected (0.08 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+-------+-------+
| Name  | Score |
+-------+-------+
| Adam  |    50 |
| Bob   |    80 |
| Adam  |    70 |
| Adam  |    10 |
| Carol |    98 |
| Bob   |    10 |
+-------+-------+
6 rows in set (0.00 sec)
Following is the query to get the sum of columns for duplicate records in MySQL −
mysql> select Name,sum(Score) from DemoTable group by Name;
This will produce the following output −
+-------+------------+
| Name  | sum(Score) |
+-------+------------+
| Adam  |        130 |
| Bob   |         90 |
| Carol |         98 |
+-------+------------+
3 rows in set (0.00 sec)
Difference between ++*p, *p++ and *++p in C

In C programming language, *p represents the value stored in a pointer. ++ is increment operator used in prefix and postfix expressions. * is dereference operator. Precedence of prefix ++ and * is same and both are right to left associative. Precedence of postfix ++ is higher than both prefix ++ and * and is left to right associative. See the below example to understand the difference between ++*p, *p++ and *++p.
 Live Demo
#include <stdio.h>
int main() {
   int arr[] = {20, 30, 40};
   int *p = arr;
   int q;
   //value of p (20) incremented by 1
   //and returned
   q = ++*p;
   printf("arr[0] = %d, arr[1] = %d, *p = %d, q = %d \n",
   arr[0], arr[1], *p, q);
   //value of p (20) is returned
   //pointer incremented by 1
   q = *p++;
   printf("arr[0] = %d, arr[1] = %d, *p = %d, q = %d \n",
   arr[0], arr[1], *p, q);
   //pointer incremented by 1
   //value returned
   q = *++p;
   printf("arr[0] = %d, arr[1] = %d, *p = %d, q = %d \n",
   arr[0], arr[1], *p, q);
   return 0;
}
arr[0] = 21, arr[1] = 30, *p = 21, q = 21
arr[0] = 21, arr[1] = 30, *p = 30, q = 21
arr[0] = 21, arr[1] = 30, *p = 40, q = 40
Virtual base class in C++

In this tutorial, we will be discussing a program to understand virtual base class in C++.
Virtual classes are primarily used during multiple inheritance. To avoid, multiple instances of the same class being taken to the same class which later causes ambiguity, virtual classes are used.
 Live Demo
#include <iostream>
using namespace std;
class A {
   public:
   int a;
   A(){
      a = 10;
   }
};
class B : public virtual A {
};
class C : public virtual A {
};
class D : public B, public C {
};
int main(){
   //creating class D object
   D object;
   cout << "a = " << object.a << endl;
   return 0;
}
a = 10
What does input() function do in python?

The function input() presents a prompt to the user (the optional arg of raw_input([arg])), gets input from the user. In Python 2.x, it returns the data input by the user in a format that is interpreted by python. For example, if the user inputs "Hello", it is stored as string while if a user enters 5, it is interpreted as an int. In Python 3.x, it returns the data input by the user in string format.
name = raw_input("What is your name? ")
print "Hello, %s." % name
Accessing element at a specific index in Julia - getindex() Method - GeeksforGeeks

07 Sep, 2021
The getindex() is an inbuilt function in julia which is used to construct array of the specified type. This function is also used to get the element of the array at a specific index. 
Syntax: getindex(type, elements...])Parameters:  
type: Specified type.
elements: Specified list of elements.
Returns: It returns the constructed array of the specified type and also the element of the array at a specific index.  
Example 1:  
Python
# Julia program to illustrate# the use of Array getindex() method # Constructing array of the different typesprintln(getindex(Int8, 1, 2, 3))println(getindex(Int16, 5, 10, 15, 20))println(getindex(Int32, 2, 4, 6, 8, 10))
Output:  
Example 2:  
Python
# Julia program to illustrate# the use of Array getindex() method # Getting an element of the 2D array# A at some specific indexs of (2, 3)# and (2, 2)A = [1 2 3; 4 5 6]println(getindex(A, 2, 2))println(getindex(A, 2, 3))
Output:  
Example 3:  
Python
# Julia program to illustrate# the use of Array getindex() method  # Getting an element of the 3D array# A at some specific indexs of (1, 2, 2)# and (1, :, 2)A = cat([1 2; 3 4],         ["hello" "Geeks"; "Welcome" "GFG"],         [5 6; 7 8], dims = 3)getindex(A, 1, 2, 2)getindex(A, 1, :, 2)
Output:  
 
rajeev0719singh
kk9826225
Julia
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Searching in Array for a given element in Julia
Get array dimensions and size of a dimension in Julia - size() Method
Get number of elements of array in Julia - length() Method
Decision Making in Julia (if, if-else, Nested-if, if-elseif-else ladder)
Getting the maximum value from a list in Julia - max() Method
Find maximum element along with its index in Julia - findmax() Method
Exception handling in Julia
Getting the absolute value of a number in Julia - abs() Method
Reverse array elements in Julia - reverse(), reverse!() and reverseind() Methods
Working with Date and Time in Julia
D3.js area() Method - GeeksforGeeks

31 Aug, 2020
The d3.area() method in D3.js is used to return an area generator with default settings that can be further used to create areas.
Syntax:
d3.area()
Parameters: This method does not accept parameters.
Return Value: This method returns no value.
Below examples illustrate the d3.area() method in D3.js:
Example 1:
HTML
<!DOCTYPE html><html>  <head>    <script src="https://d3js.org/d3.v4.min.js">    </script></head>  <body>    <h1 style="text-align: center;             color: green;">        GeeksforGeeks    </h1>      <center>        <svg id="gfg" width="200" height="200">        </svg>    </center>          <script>        var data = [            { x: 0, y: 10 },            { x: 10, y: 30 },            { x: 20, y: 150 },            { x: 50, y: 10 },            { x: 60, y: 150 },            { x: 70, y: 50 },            { x: 80, y: 190 }];          data.sort((a, b) => a.y - b.y);          var xScale = d3.scaleLinear()            .domain([0, 8])            .range([25, 200]);        var yScale = d3.scaleLinear()            .domain([0, 20])            .range([200, 25]);          // Using area() function to        // generate area        var Gen = d3.area()            .x((p) => p.x)            .y0((p) => 0)            .y1((p) => p.y);          d3.select("#gfg")            .append("path")            .attr("d", Gen(data))            .attr("fill", "green")            .attr("stroke", "black");    </script></body>  </html>
Output:
Example 2:
HTML
<!DOCTYPE html><html>  <head>    <script src="https://d3js.org/d3.v4.min.js">    </script></head>  <body>    <h1 style="text-align: center;              color: green;">        GeeksforGeeks    </h1>      <center>        <svg id="gfg" width="250" height="200">        </svg>    </center>          <script>        var points = [            { xpoint: 25, ypoint: 150 },            { xpoint: 75, ypoint: 50 },            { xpoint: 100, ypoint: 150 },            { xpoint: 100, ypoint: 50 },            { xpoint: 200, ypoint: 150 }];          // Using area() function to generate area        var Gen = d3.area()            .x((p) => p.xpoint)            .y0((p) => 0)            .y1((p) => p.ypoint);          d3.select("#gfg")            .append("path")            .attr("d", Gen(points))            .attr("fill", "green")            .attr("stroke", "black");      </script></body>  </html>
Output:
D3.js
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
Difference between var, let and const keywords in JavaScript
Difference Between PUT and PATCH Request
How to get character array from string in JavaScript?
Remove elements from a JavaScript Array
How to get selected value in dropdown list using JavaScript ?
Top 10 Front End Developer Skills That You Need in 2022
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to fetch data from an API in ReactJS ?
How to insert spaces/tabs in text using HTML/CSS?
Final local variables in C#

To set final for a local variable, use the read-only keyword in C#, since the implementation of the final keyword is not possible.
The readonly would allow the variables to be assigned a value only once. A field marked "read-only", can only be set once during the construction of an object. It cannot be changed.
Let us see an example. Below, we have set the empCount field as read-only, which once assigned cannot be changed.
class Department {
   readonly int empCount;

   Employee(int empCount) {
      this. empCount = empCount;
   }

   void ChangeCount() {
      //empCount = 150; // Compile error
   }
}
How to calculate mean of a CSV file in R? - GeeksforGeeks

26 Mar, 2021
Mean or average is a method to study central tendency of any given numeric data. It can be found using the formula.
In this article, we will be discussing two different ways to calculate the mean of a CSV file in R.
Data in use:
Method 1: Using mean function
In this method to calculate the mean of the column of a CSV file we simply use the mean() function with the column name as its parameter and this function will be returning the mean of the provided column of the CSV file.
Syntax:
mean(name of the column)
Approach
Read file
Select column
Pass the column to mean function
Display result
 Example:
R
gfg=read.csv('values.csv')  result<- mean(gfg$V1)  print(result)
Output:
[1] 5.266667
Method 2: Using  nrow() and sum() 
In this method we will be using the sum and the nrow functions separately to calculate the total number of entity in the whole csv file and there respected sum and then divide the total sum by the number of rows to get the mean.
sum() function:-Returns the sum of the respected parameter
Syntax:
sum(column_name)
nrow() function:-Returns the number of entity in the CSV file
Syntax:
nrow(name of the file)
Approach
Import file
Find sum
Find frequency
Divide sum by frequency
Store this value as mean
Display result
Example:
R
gfg=read.csv('values.csv')  mean<-sum(gfg$V1)/nrow(gfg)  mean
Output:
[1] 5.266667
Picked
R-CSV
R Language
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Change Color of Bars in Barchart using ggplot2 in R
How to Change Axis Scales in R Plots?
Group by function in R using Dplyr
How to Split Column Into Multiple Columns in R DataFrame?
How to filter R DataFrame by values in a column?
How to import an Excel File into R ?
How to filter R dataframe by multiple conditions?
Replace Specific Characters in String in R
Time Series Analysis in R
R - if statement
Get time in milliseconds using Java Calendar

Create a Calendar object.
Calendar cal = Calendar.getInstance();
For using above Calendar class, do not forget to import the following package.
import java.util.Calendar;
Now, use the getTimeInMillis() method to get the time in milliseconds.
cal.getTimeInMillis()
The following is the final example.
 Live Demo
import java.util.Calendar;
public class Demo {
   public static void main(String[] args) {
      Calendar cal = Calendar.getInstance();
      System.out.println("Milliseconds =" + cal.getTimeInMillis());
   }
}
Milliseconds =1542636999896
Consecutive elements pairing in list in Python

During data analysis using python, we may come across a need to pair-up the consecutive elements of a list. In this article we will see the various ways to achieve this.
We will design an expression to put the consecutive indexes of the list elements together. And then apply the range function to determine the maximum number of times this pairing of consecutive elements will go on.
 Live Demo
listA = [51,23,11,45]
# Given list
print("Given list A: ", listA)
# Use
res = [[listA[i], listA[i + 1]]
   for i in range(len(listA) - 1)]
# Result
print("The list with paired elements: \n",res)
Running the above code gives us the following result −
Given list A: [51, 23, 11, 45]
The list with paired elements:
[[51, 23], [23, 11], [11, 45]]
We can also take help of map and zip functions and slicing. We slice the element at position 1 and combine it with elements at position 0. We repeat this for each pair of elements using the zip and map functions.
 Live Demo
listA = [51,23,11,45]
# Given list
print("Given list A: ", listA)
# Use zip
res = list(map(list, zip(listA, listA[1:])))
# Result
print("The list with paired elements: \n",res)
Running the above code gives us the following result −
Given list A: [51, 23, 11, 45]
The list with paired elements:
[[51, 23], [23, 11], [11, 45]]
How can I create MySQL stored procedure with OUT parameter?

To make it understand we are using the table named ‘student_info’ which have the following values −
mysql> Select * from student_info;
+------+---------+------------+------------+
| id   | Name    | Address    | Subject    |
+------+---------+------------+------------+
| 101  | YashPal | Amritsar   | History    |
| 105  | Gaurav  | Jaipur     | Literature |
| 110  | Rahul   | Chandigarh | History    |
| 125  | Raman   | Shimla     | Computers  |
+------+---------+------------+------------+
4 rows in set (0.00 sec)
Now, with the help of the following query, we will create a stored procedure with OUT parameter which will count the total of a particular subject by providing the subject name as the parameter.
mysql> DELIMITER // ;
mysql> Create Procedure subjects (IN S_Subject VARCHAR(25), OUT total INT)
   -> BEGIN
   -> SELECT count(subject)
   -> INTO total
   -> FROM student_info
   -> WHERE subject = S_subject;
   -> END //
Query OK, 0 rows affected (0.00 sec)

mysql> DELIMITER ;
‘S-Subject’ is the IN parameter that is the number of subjects we want to count and ‘total’ is the OUT parameter that stores the number of subjects for a particular subject.
mysql> CALL subjects('Computers', @total);
Query OK, 1 row affected (0.02 sec)

mysql> Select @total;
+--------+
| @total |
+--------+
|      1 |
+--------+
1 row in set (0.01 sec)

mysql> CALL subjects('History', @total);
Query OK, 1 row affected (0.00 sec)

mysql> Select @total;
+--------+
| @total |
+--------+
|      2 |
+--------+
1 row in set (0.00 sec)
JSTL - Core <fmt:setLocale> Tag

The <fmt:setLocale> tag is used to store the given locale in the locale configuration variable.
The <fmt:setLocale> tag has the following attributes −
Resource bundles contain locale-specific objects. Resource bundles contain key/value pairs. When your program needs a locale-specific resource, you keep all the keys common to all the locale but you can have translated values specific to locale. Resource bundles helps in providing content specific to locale.
A Java resource bundle file contains a series of key-to-string mappings. The method that we focus on involves creating compiled Java classes that extend the java.util.ListResourceBundle class. You must compile these class files and make them available to the classpath of your Web application.
Let us define a default resource bundle as follows −
package com.tutorialspoint;

import java.util.ListResourceBundle;

public class Example_En extends ListResourceBundle {
   public Object[][] getContents() {
      return contents;
   }
   static final Object[][] contents = {
      {"count.one", "One"},
      {"count.two", "Two"},
      {"count.three", "Three"},
   };
}
Let us now define one more resource bundle which we will use for Spanish Locale −
package com.tutorialspoint;

import java.util.ListResourceBundle;

public class Example_es_ES extends ListResourceBundle {
   public Object[][] getContents() {
      return contents;
   }
   static final Object[][] contents = {
      {"count.one", "Uno"},
      {"count.two", "Dos"},
      {"count.three", "Tres"},
   };
}
Let us compile the above classes Example.class and Example_es_ES.class and make them available in the CLASSPATH of your Web application. You can now use the following JSTL tags to display the three numbers as follows −
<%@ taglib uri = "http://java.sun.com/jsp/jstl/core" prefix = "c" %>
<%@ taglib uri = "http://java.sun.com/jsp/jstl/fmt" prefix = "fmt" %>

<html>
   <head>
      <title>JSTL fmt:setLocale Tag</title>
   </head>

   <body>
      <fmt:bundle basename = "com.tutorialspoint.Example">
         <fmt:message key = "count.one"/><br/>
         <fmt:message key = "count.two"/><br/>
         <fmt:message key = "count.three"/><br/>
      </fmt:bundle>

      <!-- Change the Locale -->
      <fmt:setLocale value = "es_ES"/>
      <fmt:bundle basename = "com.tutorialspoint.Example">
         <fmt:message key = "count.one"/><br/>
         <fmt:message key = "count.two"/><br/>
         <fmt:message key = "count.three"/><br/>
      </fmt:bundle>

   </body>
</html>
The above code will generate the following result −
One 
Two 
Three
Uno
Dos
Tres

Check <fmt:bundle> and <setBundle> tags to understand the complete concept.

    108 Lectures 
     11 hours 

 Chaand Sheikh

    517 Lectures 
     57 hours 

 Chaand Sheikh

    41 Lectures 
     4.5 hours 

 Karthikeya T

    42 Lectures 
     5.5 hours 

 TELCOMA Global

    15 Lectures 
     3 hours 

 TELCOMA Global

    44 Lectures 
     15 hours 

 Uplatz
 Print
 Add Notes
 Bookmark this page
Program to find frequency of each element in a vector using map in C++

29 May, 2021
Given a vector vec, the task is to find the frequency of each element of vec using a map. Examples:  
Input: vec = {1, 2, 2, 3, 1, 4, 4, 5} Output: 1 2 2 2 3 1 4 2 5 1 Explanation: 1 has occurred 2 times 2 has occurred 2 times 3 has occurred 1 times 4 has occurred 2 times 5 has occurred 1 times Input: v1 = {6, 7, 8, 6, 4, 1} Output: 1 1 4 1 6 2 7 1 8 1 Explanation: 1 has occurred 1 times 4 has occurred 1 times 6 has occurred 2 times 7 has occurred 1 times 8 has occurred 1 times  
 
Approach: We can find the frequency of elements in a vector using given four steps efficiently:  
Traverse the elements of the given vector vec.check whether the current element is present in the map or not.If it is present, then update the frequency of the current element, else insert the element with frequency 1 as shown below:Traverse the map and print the frequency of each element stored as a mapped value.
Traverse the elements of the given vector vec.
check whether the current element is present in the map or not.
If it is present, then update the frequency of the current element, else insert the element with frequency 1 as shown below:
Traverse the map and print the frequency of each element stored as a mapped value.
Below is the implementation of the above approach: 
CPP
#include <bits/stdc++.h>using namespace std; void printFrequency(vector<int> vec){    // Define an map    map<int, int> M;     // Traverse vector vec check if    // current element is present    // or not    for (int i = 0; vec[i]; i++) {         // If the current element        // is not found then insert        // current element with        // frequency 1        if (M.find(vec[i]) == M.end()) {            M[vec[i]] = 1;        }         // Else update the frequency        else {            M[vec[i]]++;        }    }     // Traverse the map to print the    // frequency    for (auto& it : M) {        cout << it.first << ' '             << it.second << '\n';    }} // Driver Codeint main(){    vector<int> vec = { 1, 2, 2, 3, 1, 4, 4, 5 };     // Function call    printFrequency(vec);    return 0;}
1 2
2 2
3 1
4 2
5 1
 
Complexity Analysis: Time Complexity: O(n log n) For a given vector of size n, we are iterating over it once and the time complexity for searching elements in the map is O(log n). So the time complexity is O(n log n) Space Complexity: O(n) For a given vector of size n, we are using an extra map which can have maximum of n key-values, so space complexity is O(n) 
sufyankhan9678
varshagumber28
cpp-map
C++
Data Structures
Write From Home
Data Structures
CPP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Sorting a vector in C++
Polymorphism in C++
Unordered Sets in C++ Standard Template Library
Pair in C++ Standard Template Library (STL)
std::string class in C++
DSA Sheet by Love Babbar
SDE SHEET - A Complete Guide for SDE Preparation
Top 50 Array Coding Problems for Interviews
What is Hashing | A Complete Tutorial
Find if there is a path between two vertices in an undirected graph
C# | Int 64 Struct

02 May, 2019
In C#, Int64 Struct is used to represent 64-bit signed integer(also termed as long data type) starting from range -9,223,372,036,854,775,808 to +9, 223,372,036,854,775,807. It provides different types of method to perform various operations. A user can perform the mathematical operation like addition, subtraction, multiplication, etc. on Int64 type. It supports bitwise operations like AND, OR, XOR, etc. It provides full support for standard and custom numeric format strings. The user can also call the methods of Convert and Math class to perform operations on Int64 value. Int64 struct inherits the ValueType class which inherits the Object class.
Example 1:
// C# program to illustrate the // MaxValue and MinValue fieldusing System;  class GFG {      // Main method    static public void Main()    {        Int64 var1 = 89;        Int64 var2 = 50;        Int64 var3 = 10;          // Get the Maximum and Minimum value of         // Int64 type Using MaxValue and         // MinValue field        Console.WriteLine("Value 1: {0}", var1);        Console.WriteLine("Value 2: {0}", var2);        Console.WriteLine("Value 3: {0}", var3);          Console.WriteLine("Maximum Value: {0}",                               Int64.MaxValue);          Console.WriteLine("Minimum Value: {0}",                               Int64.MinValue);    }}
Value 1: 89
Value 2: 50
Value 3: 10
Maximum Value: 9223372036854775807
Minimum Value: -9223372036854775808

Example 1:
// C# program to demonstrate the // Int64.Equals(Int64) Method using System; using System.Globalization;     class GFG {         // Main Method     public static void Main()     {         // Declaring and initializing value1         long value1 = 45643212342;             // Declaring and initializing value2         long value2 = 543256344233;             // using Equals(Int64) method         bool status = value1.Equals(value2);             // checking the status         if (status)             Console.WriteLine("{0} is equal to {1}",                                     value1, value2);         else            Console.WriteLine("{0} is not equal to {1}",                                         value1, value2);     } } 
45643212342 is not equal to 543256344233

Example 2:
// C# program to illustrate the // Int64.GetTypeCode() Method using System;     class GFG {         // Main Method     public static void Main()     {             // Taking long value         // i.e. Int64         long val = 45789478123;             // Getting the typecode for Int64         // using GetTypeCode() method         TypeCode result = val.GetTypeCode();             // Display the TypeCode          Console.WriteLine("TypeCode for Int64 is: {0}",                                                result);     } } 
TypeCode for Int64 is: Int64

Reference:
https://docs.microsoft.com/en-us/dotnet/api/system.int64?view=netframework-4.7.2
CSharp-Int64-Struct
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to check interface type in TypeScript ?

29 Sep, 2020
Typescript is a pure object-oriented programming language that consists of classes, interfaces, inheritance, etc. It is strict and it statically typed like Java. Interfaces are used to define contacts in typescript. In general, it defines the specifications of an entity. Below is an example of an interface or contract of a car.
interface Audi {
    length: number;
    width: number;
    wheelbase: number;
    price:number;
    numberOfAirBags:number;
    seatingCapacity: number;
    getTyrePressure: () => number;
}
Approach:
Declare an interface with a name and its type as a string.
Now create a customized function to check the interface type.
This function returns a boolean value if the name attribute is present in the argument passed.
Now use an if statement to check the value returned by the function and can perform further operation regarding requirements.
Example 1:
Javascript
interface Student{    name:string;}  var geek:any = {     name: "Jairam"     };  function instanceOfStudent(data: any): data is Student {    return 'name' in data;}  if (instanceOfStudent(geek)) {    document.write("Student Name is "+ geek.name);}
Output: 
Example 2:
Javascript
interface Bike{    companyName:string;    bikeNumber:any;    modelNo:any;}  var bike:any = {     companyName: "Engfield"     };  function createName(name:any){   alert(name);}  if(instanceOfBike(bike)) {    createName(bike.companyName)}else{    createName("No Name is registered with that company name")}  function instanceOfBike(data: any): data is Bike {    return 'companyName' in data;}
Output: 
Picked
TypeScript
JavaScript
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.