code-rag-bench/online-tutorials huggingface dataset:
Clojure - Lists

List is a structure used to store a collection of data items. In Clojure, the List implements the ISeq interface. Lists are created in Clojure by using the list function.
Following is an example of creating a list of numbers in Clojure.
(ns clojure.examples.example
   (:gen-class))
(defn example []
   (println (list 1 2 3 4)))
(example)
The above code produces the following output.
(1 2 3 4)

Following is an example of creating a list of characters in Clojure.
(ns clojure.examples.example
   (:gen-class))
(defn example []
   (println (list 'a 'b 'c 'd)))
(example)
The above code produces the following output.
(a b c d)

Following are the list methods available in Clojure.
Creates a new list containing the items prepended to the rest, the last of which will be treated as a sequence.
This function returns the first item in the list.
This function returns the item in the ‘nth’ position in the list.
Returns a new list wherein an element is added to the beginning of the list.
Returns a new list wherein the list is at the beginning and the elements to be appended are placed at the end.
Returns the remaining items in the list after the first item.
 Print
 Add Notes
 Bookmark this page
C# Program to perform Celsius to Fahrenheit Conversion

Firstly, set the Celsius temperature −
double celsius = 36;
Console.WriteLine("Celsius: " + celsius);
Now convert it into Fahrenheit:
fahrenheit = (celsius * 9) / 5 + 32;
You can try to run the following code to convert Celsius to Fahrenheit.
Live Demo
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Demo {

   class MyApplication {

      static void Main(string[] args) {

         double fahrenheit;

         double celsius = 36;
         Console.WriteLine("Celsius: " + celsius);

         fahrenheit = (celsius * 9) / 5 + 32;
         Console.WriteLine("Fahrenheit: " + fahrenheit);

         Console.ReadLine();
      }
   }
}
Celsius: 36
Fahrenheit: 96.8
How to find the previous and next record using a single query in MySQL?

You can use UNION to get the previous and next record in MySQL.
The syntax is as follows
(select *from yourTableName WHERE yourIdColumnName > yourValue ORDER BY
yourIdColumnName ASC LIMIT 1)
UNION
(select *from yourTableName WHERE yourIdColumnName < yourValue ORDER BY
yourIdColumnName DESC LIMIT 1);
To understand the concept, let us create a table. The query to create a table is as follows
mysql> create table previousAndNextRecordDemo
   - > (
   - > Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,
   - > Name varchar(30)
   - > );
Query OK, 0 rows affected (1.04 sec)
Insert some records in the table using insert command.
The query is as follows
mysql> insert into previousAndNextRecordDemo(Name) values('John');
Query OK, 1 row affected (0.17 sec)
mysql> insert into previousAndNextRecordDemo(Name) values('Sam');
Query OK, 1 row affected (0.15 sec)
mysql> insert into previousAndNextRecordDemo(Name) values('Carol');
Query OK, 1 row affected (0.14 sec)
mysql> insert into previousAndNextRecordDemo(Name) values('Bob');
Query OK, 1 row affected (0.17 sec)
mysql> insert into previousAndNextRecordDemo(Name) values('Larry');
Query OK, 1 row affected (0.20 sec)
mysql> insert into previousAndNextRecordDemo(Name) values('David');
Query OK, 1 row affected (0.14 sec)
mysql> insert into previousAndNextRecordDemo(Name) values('Ramit');
Query OK, 1 row affected (0.12 sec)
mysql> insert into previousAndNextRecordDemo(Name) values('Maxwell');
Query OK, 1 row affected (0.15 sec)
mysql> insert into previousAndNextRecordDemo(Name) values('Mike');
Query OK, 1 row affected (0.14 sec)
mysql> insert into previousAndNextRecordDemo(Name) values('Robert');
Query OK, 1 row affected (0.19 sec)
mysql> insert into previousAndNextRecordDemo(Name) values('Chris');
Query OK, 1 row affected (0.10 sec)
mysql> insert into previousAndNextRecordDemo(Name) values('James');
Query OK, 1 row affected (0.16 sec)
mysql> insert into previousAndNextRecordDemo(Name) values('Jace');
Query OK, 1 row affected (0.15 sec)
Display all records from the table using select statement.
The query is as follows
mysql> select *from previousAndNextRecordDemo;
The following is the output
+----+---------+
| Id | Name    |
+----+---------+
|  1 | John    |
|  2 | Sam     |
|  3 | Carol   |
|  4 | Bob     |
|  5 | Larry   |
|  6 | David   |
|  7 | Ramit   |
|  8 | Maxwell |
|  9 | Mike    |
| 10 | Robert  |
| 11 | Chris   |
| 12 | James   |
| 13 | Jace    |
+----+---------+
13 rows in set (0.00 sec)
Here is the query to get previous and next record using a single query with UNION
mysql> (select *from previousAndNextRecordDemo WHERE Id > 8 ORDER BY Id ASC LIMIT 1)
   - > UNION
   - > (select *from previousAndNextRecordDemo WHERE Id < 8 ORDER BY Id DESC LIMIT 1);
The following is the output
+----+-------+
| Id | Name  |
+----+-------+
|  9 | Mike  |
|  7 | Ramit |
+----+-------+
2 rows in set (0.03 sec)
Tryit Editor v3.7

Tryit: Multiple shadows
How to change the font properties of a Matplotlib colorbar label?

To change the font properties of a matplotlib colorbar label, we can take the following steps −
Set the figure size and adjust the padding between and around the subplots.
Set the figure size and adjust the padding between and around the subplots.
Create x, y and z data points using numpy.
Create x, y and z data points using numpy.
Use imshow() method to display the data as an image, i.e., on a 2D regular raster.
Use imshow() method to display the data as an image, i.e., on a 2D regular raster.
Create a colorbar for a ScalarMappable instance, *mappable*.
Create a colorbar for a ScalarMappable instance, *mappable*.
Using colorbar axes, set the font properties such that the label is bold.
Using colorbar axes, set the font properties such that the label is bold.
To display the figure, use show() method.
To display the figure, use show() method.
import numpy as np
import matplotlib.pyplot as plt

plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True

x, y = np.mgrid[-1:1:100j, -1:1:100j]
z = (x + y) * np.exp(-5.0 * (x ** 2 + y ** 2))

plt.imshow(z, extent=[-1, 1, -1, 1])

cb = plt.colorbar
cb.set_label(label='my color bar label', weight='bold')

plt.show()
How to set cookies expiry date in JavaScript?

Extend the life of a cookie beyond the current browser session by setting an expiration date and saving the expiry date within the cookie. This can be done by setting the ‘expires’ attribute to a date and time.
You can try to run the following example to set the expiry date of a cookie by 1 Month −
<html>
   <head>
      <script>
         <!--
            function WriteCookie() {
               var now = new Date();
               now.setMonth( now.getMonth() + 1 );
               cookievalue = escape(document.myform.customer.value) + ";"

               document.cookie="name=" + cookievalue;
               document.cookie = "expires=" + now.toUTCString() + ";"
               document.write ("Setting Cookies : " + "name=" + cookievalue );
            }
         //-->
      </script>
   </head>
   <body>
      <form name="myform" action="">
         Enter name: <input type="text" name="customer"/>
         <input type="button" value="Set Cookie" onclick="WriteCookie()"/>
      </form>
   </body>
</html>
Operations on Queue in Data Structures

Queue is First In First Out data structure. The queue is used in different area for graph traversal algorithms Breadth First Search etc. The queue has some primitive operations. Here we will see those operations of queue, and see one example using the queue ADT.
The ADT (abstract datatype) is special kind of datatype, whose behavior is defined by a set of values and set of operations. The keyword “Abstract” is used as we can use these datatypes, we can perform different operations. But how those operations are working that is totally hidden from the user. The ADT is made of with primitive datatypes, but operation logics are hidden.
These are few operations or functions of the queue ADT.
isFull(), This is used to check whether queue is full or not
isEmpry(), This is used to check whether queue is empty or not
enqueue(x), This is used to push x at the end of the queue
delete(), This is used to delete one element from the front end of the
front(), This is used to get the front most element of the queue
size(), this function is used to get number of elements present into the queue
 Live Demo
#include<iostream>
#include<queue>
using namespace std;
main(){
   queue<int> que;
   if(que.empty()){
      cout << "Queue is empty" << endl;
   } else {
      cout << "Queue is not empty" << endl;
   }
   //insert elements into queue
   que.push(10);
   que.push(20);
   que.push(30);
   que.push(40);
   que.push(50);
   cout << "Size of the queue: " << que.size() << endl;
   //delete and dispay elements
   while(!que.empty()) {
      int item = que.front(); // read element from first position
      que.pop();
      cout << item << " ";
   }
}
Queue is empty
Size of the queue: 5
10 20 30 40 50
What are the different modes of parameters used by MySQL stored procedure?

Parameters make the stored procedure more useful and flexible. In MySQL, we have the following three kinds of modes −
It is the default mode. When we define an IN parameter in a stored procedure, the calling program has to pass an argument to the stored procedure. The value of an IN parameter is protected which means that even the value of the IN parameter is changed inside the stored procedure; its original value is retained after the stored procedure ends.
The value of an OUT parameter can be changed inside the stored procedure and its new value is passed back to the calling program. It is to be noticed that the stored procedure cannot access the initial value of the OUT parameter when it starts.
An INOUT parameter is the combination of IN and OUT parameters which means that the calling program may pass the argument, and the stored procedure can modify the INOUT parameter and pass the new value back to the calling program.
Following is the syntax of defining a parameter in the stored procedure −
MODE parameter_name parameter_type(parameter_size)
Here, MODE can be IN, OUT or INOUT which depends upon the purpose of the parameter in the stored purpose.
Parameter_name is the name of the parameter.
Parameter_type is the data type of parameter.
Parameter_size is the size of the parameter
Iterate through a LinkedList in reverse direction using a ListIterator in Java

A ListIterator can be used to traverse the elements in the forward direction as well as the
reverse direction in a LinkedList. The method hasPrevious( ) in ListIterator returns true if there
are more elements in the LinkedList while traversing in the reverse direction and false
otherwise. The method previous( ) returns the previous element in the LinkedList and reduces
the cursor position backward.
A program that demonstrates this is given as follows.
 Live Demo
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
public class Demo {
   public static void main(String[] args) {
      List l = new LinkedList();
      l.add("John");
      l.add("Sara");
      l.add("Susan");
      l.add("Betty");
      l.add("Nathan");
      ListIterator i = l.listIterator(l.size());
      System.out.println("The LinkedList elements in the reverse direction are: ");
      while (i.hasPrevious()) {
         System.out.println(i.previous());
      }
   }
}
The output of the above program is as follows
The LinkedList elements in the reverse direction are:
Nathan
Betty
Susan
Sara
John
Now let us understand the above program.
The LinkedList is created and LinkedList.add() is used to add the elements to the LinkedList. A
code snippet which demonstrates this is as follows
List l = new LinkedList();
l.add("John");
l.add("Sara");
l.add("Susan");
l.add("Betty");
l.add("Nathan");
Then the ListIterator interface is used to display the LinkedList elements in the reverse direction.
A code snippet which demonstrates this is as follows
ListIterator i = l.listIterator(l.size());
System.out.println("The LinkedList elements in the reverse direction are: ");
while (i.hasPrevious()) {
   System.out.println(i.previous());
}
How to check whether a thread is alive or not in C#

To check whether a thread is alive or not, the code is as follows −
 Live Demo
using System;
using System.Threading;
public class Demo {
   public static void Main() {
      Thread thread = new Thread(new ThreadStart(demo1));
      thread = Thread.CurrentThread;
      Console.WriteLine("Is the thread alive? = "+thread.IsAlive);
      ThreadPool.QueueUserWorkItem(new WaitCallback(demo2));
      Console.WriteLine("Current state of Thread = "+thread.ThreadState);
      Console.WriteLine("ManagedThreadId = "+thread.ManagedThreadId);
      thread.IsBackground = true;
      Console.WriteLine("Is the Thread a background thread? = "+thread.IsBackground);
   }
   public static void demo1() {
      Thread.Sleep(2000);
   }
   public static void demo2(object stateInfo) {
      Console.WriteLine("Thread belongs to managed thread pool? = "+Thread.CurrentThread.IsThreadPoolThread);
   }
}
This will produce the following output −
Is the thread alive? = True
Current state of Thread = Running
ManagedThreadId = 775
Is the Thread a background thread? = True
Thread belongs to managed thread pool? = True
Let us now see another example −
 Live Demo
using System;
using System.Threading;
public class Demo {
   public static void Main() {
      Thread thread = new Thread(new ThreadStart(demo));
      thread.Start();
      Console.WriteLine("Is the Thread alive? "+thread.IsAlive);
   }
   public static void demo() {
      Console.WriteLine("Thread belongs to managed thread pool? = "+Thread.CurrentThread.IsThreadPoolThread);
   }
}
This will produce the following output −
Is the Thread alive? True
Thread belongs to managed thread pool? = False
Program to check whether list of points form a straight line or not in Python

Suppose we have a list coordinates in a Cartesian plane, we have to check whether the coordinates form a straight line segment or not.
So, if the input is like coordinates = [(5, 5),(8, 8),(9, 9)], then the output will be True, as these points are forming a line segment with a slope 1.
To solve this, we will follow these steps −
(x0, y0) := coordinates[0]
(x1, y1) := coordinates[1]
for i in range 2 to size of coordinates list - 1, do(x, y) := coordinates[i]if (x0 - x1) * (y1 - y) is not same as (x1 - x) * (y0 - y1), thenreturn False
(x, y) := coordinates[i]
if (x0 - x1) * (y1 - y) is not same as (x1 - x) * (y0 - y1), thenreturn False
return False
return True
Let us see the following implementation to get better understanding −
 Live Demo
class Solution:
   def solve(self, coordinates):
      (x0, y0), (x1, y1) = coordinates[0], coordinates[1]
      for i in range(2, len(coordinates)):
         x, y = coordinates[i]
         if (x0 - x1) * (y1 - y) != (x1 - x) * (y0 - y1):
            return False
      return True
ob = Solution()
coordinates = [[5, 5],[8, 8],[9, 9]]
print(ob.solve(coordinates))
[[5, 5],[8, 8],[9, 9]]
True
JavaScript Array reverse() Method - GeeksforGeeks

04 Oct, 2021
Below is the example of Array reverse() method.
Example:<script>function func() {      // Original Array    var arr = ['Portal', 'Science',                'Computer', 'GeeksforGeeks'];    document.write(arr);      // Reversed array    var new_arr = arr.reverse();    document.write("<br>");    document.write(new_arr);}func();</script>                    
<script>function func() {      // Original Array    var arr = ['Portal', 'Science',                'Computer', 'GeeksforGeeks'];    document.write(arr);      // Reversed array    var new_arr = arr.reverse();    document.write("<br>");    document.write(new_arr);}func();</script>                    
Output:Portal,Science,Computer,GeeksforGeeks
GeeksforGeeks,Computer,Science,Portal
Portal,Science,Computer,GeeksforGeeks
GeeksforGeeks,Computer,Science,Portal
The arr.reverse() method is used for in-place reversal of the array. The first element of the array becomes the last element and vice versa.
Syntax:
arr.reverse()
Parameters: This method does not accept any parameter
Return value: This method returns the reference of the reversed original array.
Below examples illustrate the JavaScript Array reverse() method:
Example 1: In this example the reverse() method reverses the sequence of the array elements of arr.var arr = [34, 234, 567, 4];
print(arr);
var new_arr = arr.reverse();
print(new_arr);
Output:34, 234, 567, 4
4, 567, 234, 34

var arr = [34, 234, 567, 4];
print(arr);
var new_arr = arr.reverse();
print(new_arr);

Output:
34, 234, 567, 4
4, 567, 234, 34

Code for the above method is provided below:Program 1:
<script>function func() {      // Original Array    var arr = [34, 234, 567, 4];    document.write(arr);      // Reversed array    var new_arr = arr.reverse();    document.write("<br>");    document.write(new_arr);}func();</script>
Output:
34, 234, 567, 4
4, 567, 234, 34
Supported Browsers: The browsers supported by JavaScript Array reverse() method are listed below:
Google Chrome 1.0 and above
Microsoft Edge 12 and above
Mozilla Firefox 1.0 and above
Safari 1 and above
Opera 4 and above
ysachin2314
javascript-array
JavaScript-Methods
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
Convert a string to an integer in JavaScript
Differences between Functional Components and Class Components in React
How to append HTML code to a div using JavaScript ?
How to Open URL in New Tab 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?
What is difference between <button> vs. <input type="button" />?

In HTML, <input type="button" /> is used to create buttons in an HTML form. Inside the <button> tag, you can place content like text or images. But, this is not the case with the buttons created with <input> tag.
Let’s see an example of button and <input type=”button” />,
It is used for creating a button within an HTML form and inside the <button> tag, you can place content like text or images.
The following will add an image to a button −
You can try to run the following code to add an image to a button using the <button> tag −
<!DOCTYPE html>
<html>
   <body>
      <button onclick="alert('Learn HTML')">
         <img src="https://www.tutorialspoint.com/html/images/html-mini-logo.jpg"
            alt="Learn HTML" height="80" width="100">
      </button>
   </body>
</html>
Submit button automatically submits a form on click. Using HTML forms, you can easily take user input. The <form> tag is used to get user input, by adding the form elements. The type attribute is used to add a button inside the <input> tag.
You can try to run the following code to learn about the usage of <input type=”button”>
<!DOCTYPE html>
<html>
   <head>
      <title>HTML Button</title>
   </head>

   <body>
      <form action="/new.php">
         Student Name:<br>
         <input type="text" name="sname">
         <br>
         Student Subject:<br>
         <input type="text" name="ssubject">
         <br>
         <input type="submit" value="Submit">
      </form>
   </body>
</html>
Java Program to create Character Array from String Objects

Use the toCharArray() method in Java to create character arrays from string objects. The following is our string.
String str = "This is it!";
Now, let us create character array from the above string.
char[] strArr = str.toCharArray();
 Live Demo
public class Demo {
   public static void main(String[] args) {
      String str = "This is it!";
      char[] strArr = str.toCharArray();
      for(char res: strArr) {
         System.out.println(res);
      }
   }
}
T
h
i
s

i
s

i
t
!
Let us see another example in which we are creating string using new operator.
 Live Demo
public class Demo {
   public static void main(String[] args) {
      String str = new String("This is another string!");
      char[] strArr = str.toCharArray();
      for(char res: strArr) {
         System.out.println(res);
      }
   }
}
T
h
i
s

i
s

a
n
o
t
h
e
r

s
t
r
i
n
g
!
How to concatenate a string with  numbers in Python?

To concatenate a string with numbers, you need to cast the numbers to string using str(number). For example,
>>> a = "string"
>>> b = 1
>>> print a + str(b)
string1
In Python 2, you can also use backtick(``) to surround the number and get the same result with numbers and strings. Note that backticks have been removed from Python 3. For example,
>>> a = "string"
>>> b = 1
>>> print a + `b`
string1
PHP | is_array() Function - GeeksforGeeks

06 Jan, 2020
The is_array() is an inbuilt function in PHP. The is_array() function is used to check whether a variable is an array or not.
Syntax:
bool is_array($variable_name)
Parameter: This function accept a single parameter as mentioned above and described below:$variable_name: This parameter holds the variable we want to check.
Return value: It is a boolean function so returns TRUE when $variable_name is a boolean value, otherwise FALSE.
Below example illustrate the is_array() function in PHP.Example 1:
<?php// PHP code to demonstrate working of is_array()$variable_name1=67.099;$variable_name2=32;$variable_name3="abc";$variable_name4=array('A', 'B', 'C');  // $variable_name4 is an array, returns TRUEif (is_array($variable_name4))    echo "array('A', 'B', 'C') is an array . \n";else    echo "array('A', 'B', 'C') is not a array value. \n";    // $variable_name1 is not array, gives FALSEif (is_array($variable_name1))    echo "$variable_name1 is a array value. \n";else    echo "$variable_name1 is not a array value. \n";  // $variable_name2 is not array, gives FALSEif (is_array($variable_name2))    echo "$variable_name2 is a array value. \n";else    echo "$variable_name2 is not a array value. \n";  // $variable_name3 is not array, gives FALSEif (is_array($variable_name3))    echo "$variable_name3 is a array value. \n";else    echo "$variable_name3 is not a array value. \n";?>
array('A', 'B', 'C') is an array . 
67.099 is not a array value. 
32 is not a array value. 
abc is not a array value.

Reference: http://php.net/manual/en/function.is-array.php
PHP-array
PHP
Web Technologies
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to convert array to string in PHP ?
How to fetch data from localserver database and display on HTML table using PHP ?
PHP | Converting string to Date and DateTime
How to display logged in user information in PHP ?
Download file from URL using PHP
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
How to insert spaces/tabs in text using HTML/CSS?
SQL CREATE TABLE Statement

The CREATE TABLE statement is used to create a new table in a database.
The column parameters specify the names of the columns of the table.
The datatype parameter specifies the type of data the column can hold (e.g. varchar, integer, date, etc.).
Tip: For an overview of the available data types, 
go to our complete Data Types Reference.
The following example creates a table called "Persons" that contains five columns: PersonID, LastName, FirstName, 
Address, and City:
The PersonID column is of type int and will hold an integer.
The LastName, FirstName, Address, and City columns are of
type varchar and will hold characters, and the maximum length for these fields 
is 255 characters.
The empty "Persons" table will now look like this:
Tip: The empty "Persons" table can now be filled with data with the 
SQL INSERT INTO statement.
A copy of an existing table can also be created using 
CREATE TABLE.
The new table gets the same column definitions. All columns or specific 
columns can be selected.
If you create a new table using an existing table, the new table will be 
filled with the existing values from the old table.
The following SQL creates a new table called "TestTables" (which is 
a copy of the "Customers" table): 
Write the correct SQL statement to create a new table called Persons.
 (
  PersonID int,
  LastName varchar(255),
  FirstName varchar(255),
  Address varchar(255),
  City varchar(255) 
);

Start the Exercise
We just launchedW3Schools videos
Get certifiedby completinga course today!
If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:
help@w3schools.com
Your message has been sent to W3Schools.
How to make a method deprecated in C#?

The Obsolete Attribute marks elements like classes, methods, properties, fields, delegates, and many others within our code as deprecated or obsolete. The attribute is read at compile time and it is used to generate a warning or an error to the developer.
This attribute can help if we have ever wanted to make sure programmers use newer versions of methods. It also makes it easier when we are transitioning from older methods to newer ones. Marking an item as obsolete warns users that program elements will be removed in future versions of the code base.
This attribute is found in the System namespace. The Obsolete attribute decorates a program element by putting the word “Obsolete” above it inside square brackets. Since it is an attribute, we can use either Obsolete or ObsoleteAttribute.
Obsolete attribute has three constructors −
[Obsolete] − is a no parameter constructor and is a default using this attribute.
[Obsolete] − is a no parameter constructor and is a default using this attribute.
[Obsolete(string message)] − in this format we get message of why this method is deprecated.
[Obsolete(string message)] − in this format we get message of why this method is deprecated.
[Obsolete(string message, bool error)] − in this format along with the message we can control whether the complier should throw error during the compilation time.
[Obsolete(string message, bool error)] − in this format along with the message we can control whether the complier should throw error during the compilation time.
using System;
namespace DemoApplication{
   class Demo{
      static void Main(string[] args){
         ObseleteMethod();
         ObseleteMethodWithMessage();
         ObseleteMethodWithMessageAndNoFail();
         ObseleteMethodWithMessageAndFail();
      }
      [Obsolete]
      public static void ObseleteMethod() { }
      [Obsolete("This Method is Deprecated")]
      public static void ObseleteMethodWithMessage() { }
      [Obsolete("This Method is Deprecated", false)]
      public static void ObseleteMethodWithMessageAndNoFail() { }
      [Obsolete("This Method is Deprecated", true)]
      public static void ObseleteMethodWithMessageAndFail() { }
   }
}
The output of the above code is
C Program Coin Change

In this problem, we are given a value n, and we want to make change of n rupees, and we have n number of coins each of value ranging from 1 to m. And we have to return the total number of ways in which make the sum.
Input : N = 6 ; coins = {1,2,4}.
Output : 6
Explanation : The total combination that make the sum of 6
is :
{1,1,1,1,1,1} ; {1,1,1,1,2}; {1,1,2,2}; {1,1,4}; {2,2,2} ; {2,4}.
#include <stdio.h>
int coins( int S[], int m, int n ) {
   int i, j, x, y;
   int table[n+1][m];
   for (i=0; i<m; i++)
      table[0][i] = 1;
   for (i = 1; i < n+1; i++) {
      for (j = 0; j < m; j++) {
         x = (i-S[j] >= 0)? table[i - S[j]][j]: 0;
         y = (j >= 1)? table[i][j-1]: 0;
         table[i][j] = x + y;
      }
   }
   return table[n][m-1];
}
int main() {
   int arr[] = {1, 2, 3};
   int m = sizeof(arr)/sizeof(arr[0]);
   int n = 4;
   printf("The total number of combinations of coins that sum up to %d",n);
   printf(" is %d ", coins(arr, m, n));
   return 0;
}
The total number of combinations of coins that sum up to 4 is 4
Write a program in Java to rotate a matrix by 90 degrees in anticlockwise direction

Let’s suppose we have given a square matrix of N×N. The task is to rotate the matrix counterclockwise. For example,
Input-1 −
N = 3
matrix[ ][ ] = [
   [1 2 3],
   [4 5 6],
   [7 8 9]
]
Output −
3 6 9 2 5 8 1 4 7
Explanation: After rotating the matrix counterclockwise it will generate the output as, 3 6 9 2 5 8 1 4 7.
Initially the idea is to find the transpose of the given matrix and then swap each of the elements of the matrix while traversing row-wise.
Take Input of a square matrix.
Take Input of a square matrix.
Find the transpose of the matrix.
Find the transpose of the matrix.
Swap the element at index 0 with index n-1.
Swap the element at index 0 with index n-1.
Return the output.
Return the output.
import java.io.*;
class Solution {
   static void rotateMatrix(
      int n, int matrix[][]){
         for (int i = 0; i < n; i++) {
            for (int j = i; j < n; j++) {
               int temp= matrix[i][j];
               matrix[i][j]= matrix[j][i];
               matrix[j][i]= temp;
            }
         }
   for(int i=0;i<n;i++){
      int top=0;
      int bottom = n-1;
      while(top<bottom){
         int temp = matrix[top][i];
         matrix[top][i]=matrix[bottom][i];
         matrix[bottom][i] = temp;
         top++;
         bottom--;
      }
   }
}
static void displayMatrix(int N, int mat[][]){
   for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++)
         System.out.print(" " + mat[i][j]);
         System.out.print("\n");
      }
      System.out.print("\n");
   }
   public static void main(String[] args){
      int N = 3;
      int mat[][] = {
         {1,2,3},
         {4,5,6},
         {7,8,9}
      };
      rotateMatrix(N, mat);
      displayMatrix(N, mat);
   }
}
Running the above code will generate the output as,
3 6 9 2 5 8 1 4 7
What are static methods in a Python class?

Any python class has three types of methods like the instance methods, class methods and the static methods.
Consider the code
class OurClass:
    def method(self):
        return 'instance method called', self
     @classmethod
    def classmethod(cls):
        return 'class method called', cls
     @staticmethod
    def staticmethod():
        return 'static method called'
The third method, OurClass.staticmethod was marked with a @staticmethod decorator to flag it as a static method.
This type of method takes neither a self nor a cls parameter but it can accept an arbitrary number of other parameters.
Therefore a static method can neither modify object state nor class state. Static methods are restricted in what data they can access - and they’re primarily a way to namespace your methods. We can call the staticmethod from above code as follows 
>>> obj = OurClass()
>>> obj.staticmethod()
'static method called'
ISRO | ISRO CS 2018 | Question 19 - GeeksforGeeks

02 Jul, 2018
A doubly linked list is declared as
struct Node {
       int Value;
       struct Node *Fwd;
       struct Node *Bwd;
);
Where Fwd and Bwd represent forward and backward link to the adjacent elements of the list. Which of the following segments of code deletes the node pointed to by X from the doubly linked list, if it is assumed that X points to neither the first nor the last node of the list?
(A) X->Bwd->Fwd = X->Fwd; X->Fwd->Bwd = X->Bwd ;(B) X->Bwd.Fwd = X->Fwd ; X.Fwd->Bwd = X->Bwd ;(C) X.Bwd->Fwd = X.Bwd ; X->Fwd.Bwd = X.Bwd ;(D) X->Bwd->Fwd = X->Bwd ; X->Fwd->Bwd = X->Fwd;Answer: (A)Explanation:Quiz of this QuestionPlease comment below if you find anything wrong in the above post
ISRO
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
ISRO | ISRO CS 2016 | Question 29
ISRO | ISRO CS 2017 - May | Question 17
ISRO | ISRO CS 2017 | Question 54
ISRO | ISRO CS 2007 | Question 55
ISRO | ISRO CS 2017 - May | Question 40
ISRO | ISRO CS 2007 | Question 80
ISRO | ISRO CS 2017 - May | Question 13
ISRO | ISRO CS 2013 | Question 54
ISRO | ISRO CS 2013 | Question 51
ISRO | ISRO CS 2016 | Question 49
Julia global Keyword | Creating a global variable in Julia

26 Mar, 2020
Keywords in Julia are reserved words whose value is pre-defined to the compiler and can not be changed by the user. These words have a specific meaning and perform their specific operation on execution.
'global' keyword in Julia is used to access a variable that is defined in the global scope. It makes the variable where it is used as its current scope and refers to the global variable of that name.Syntax:
var1 = value1
loop condition
    statement
    global var1 = value2
    statement
end

Example 1:
# Julia program to illustrate # the use of global variable  for i in 1:10    global x = iend  # Accessing global variable # from outside of the loopprintln(x)
Output:
10

With the use of global variable, the value of variable x can be accessed from anywhere in the code.
Example 2:
# Julia program to illustrate # the use of global variable  x = 0  # Defining functionfunction check_global()    for i in 1:5              # Re-defining global variable        global x = i * 2        println(x)    end    println(x)end  # Function callcheck_global()
Output:
2
4
6
8
10
10

In the above code, it can be seen that the loop will redefine the value of the global variable and when it is called outside of the loop, the updated value is printed.
Julia-keywords
Julia
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Exception handling 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)
Searching in Array for a given element in Julia
NamedTuple in Julia
Find maximum element along with its index in Julia - findmax() Method
Getting the maximum value from a list in Julia - max() Method
Join an array of strings into a single string in Julia - join() Method
Reverse array elements in Julia - reverse(), reverse!() and reverseind() Methods
Python program to find the sum of all even and odd digits of an integer list

01 Nov, 2020
The following article shows how given an integer list, we can produce the sum of all its odd and even digits.
Input : test_list = [345, 893, 1948, 34, 2346] Output : Odd digit sum : 36 Even digit sum : 40 Explanation : 3 + 5 + 9 + 3 + 1 + 9 + 3 + 3 = 36, odd summation.Input : test_list = [345, 893] Output : Odd digit sum : 20 Even digit sum : 12 Explanation : 4 + 8 = 12, even summation. 
Method 1 : Using loop, str() and int()
In this, we first convert each element to string and then iterate for each of its element, and add to respective summation by conversion to integer.
Python3
# initializing listtest_list = [345, 893, 1948, 34, 2346]  # printing original listprint("The original list is : " + str(test_list))  odd_sum = 0even_sum = 0  for sub in test_list:    for ele in str(sub):                  # adding in particular summation according to value         if int(ele) % 2 == 0:            even_sum += int(ele)        else:            odd_sum += int(ele)  # printing result print("Odd digit sum : " + str(odd_sum))print("Even digit sum : " + str(even_sum))
Output:
The original list is : [345, 893, 1948, 34, 2346]
Odd digit sum : 36
Even digit sum : 40
Method 2 : Using loop and sum()
In this, we perform task of getting summation using sum(), and loop is used to perform the task of iterating through each element.
Python3
# initializing listtest_list = [345, 893, 1948, 34, 2346]  # printing original listprint("The original list is : " + str(test_list))  odd_sum = 0even_sum = 0  for sub in test_list:          # sum() used to get summation of even and odd elements    odd_sum += sum([int(ele) for ele in str(sub) if int(ele) % 2 == 1])    even_sum += sum([int(ele) for ele in str(sub) if int(ele) % 2 == 0])  # printing result print("Odd digit sum : " + str(odd_sum))print("Even digit sum : " + str(even_sum))
Output:
The original list is : [345, 893, 1948, 34, 2346]
Odd digit sum : 36
Even digit sum : 40
Python list-programs
Python
Python Programs
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
Python | os.path.join() method
Defaultdict in Python
Python | Get dictionary keys as a list
Python | Convert a list to dictionary
Python | Convert string dictionary to dictionary
Python Program for Fibonacci numbers
MATLAB - Transpose of a Vector

The transpose operation changes a column vector into a row vector and vice versa. The transpose operation is represented by a single quote (').
Create a script file with the following code −
r = [ 1 2 3 4 ];
tr = r';
v = [1;2;3;4];
tv = v';
disp(tr); disp(tv);
When you run the file, it displays the following result −
   1
   2
   3
   4

   1     2     3     4
How to sort an Array in descending order using STL in C++?

19 Mar, 2019
Given an array arr[], sort this array in descending order using STL in C++.
Example:
Input: arr[] = {1, 45, 54, 71, 76, 12}
Output: {76, 71, 54, 45, 12, 1}

Input: arr[] = {1, 7, 5, 4, 6, 12}
Output: {12, 7, 6, 5, 4, 1}

Approach: Sorting can be done with the help of sort() function provided in STL.
Syntax:
sort(arr, arr + n, greater<T>());

// C++ program to sort Array// in descending order// using sort() in STL  #include <bits/stdc++.h>using namespace std;  int main(){    // Get the array    int arr[] = { 1, 45, 54, 71, 76, 12 };      // Compute the sizes    int n = sizeof(arr) / sizeof(arr[0]);      // Print the array    cout << "Array: ";    for (int i = 0; i < n; i++)        cout << arr[i] << " ";      // Sort the array in descending order    sort(arr, arr + n, greater<int>());      // Print the sorted array    cout << "\nDescending Sorted Array:\n";    for (int i = 0; i < n; i++)        cout << arr[i] << " ";    return 0;}
Array: 1 45 54 71 76 12 
Descending Sorted Array:
76 71 54 45 12 1

cpp-array
STL
C++
C++ Programs
STL
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++
std::string class in C++
Friend class and function in C++
Pair in C++ Standard Template Library (STL)
Header files in C/C++ and its uses
Sorting a Map by value in C++ STL
Program to print ASCII Value of a character
How to return multiple values from a function in C or C++?
C++ program for hashing with chaining
PHP | shuffle() Function

11 Jun, 2021
The shuffle() Function is a builtin function in PHP and is used to shuffle or randomize the order of the elements in an array. This function assigns new keys for the elements in the array. It will also remove any existing keys, rather than just reordering the keys and assigns numeric keys starting from zero.
Syntax: 
boolean shuffle($array)
Parameter: This function accepts a single parameter $array. It specifies the array we want to shuffle.
Return Value: This function returns a boolean value i.e., either True or False. It returns TRUE on success and FALSE on failure.
Note: This function will work for PHP version 4+.
Examples:  
Input:- array("a"=>"Ram", 
              "b"=>"Shita", 
              "c"=>"Geeta", 
              "d"=>"geeksforgeeks" )
Output:- array( [0] => Geeta,
                [1] => Shita,
                [2] => Ram,
                [3] => geeksforgeeks )
Explanation: Here as we can see that input contain elements 
             in a order but in output order become shuffled.
Below programs illustrates the working of shuffle() in PHP:  
When the input array is an associative array, then the shuffle() function will randomize the order of elements as well as assigns new keys to the elements starting from zero (0).
PHP
<?php // input array contain some elements which// need to be shuffled.$a = array     (         "a"=>"Ram",        "b"=>"Shita",        "c"=>"Geeta",        "d"=>"geeksforgeeks"     ); shuffle($a);print_r($a); ?>
Output: 
Array
(
    [0] => geeksforgeeks
    [1] => Shita
    [2] => Ram
    [3] => Geeta
)
When the input array is not associative then the shuffle() function will randomize the order and convert the array to an associative array with keys starting from zero (0).
PHP
<?php // input array contain some elements// which need to be shuffled.$a = array     (        "ram",        "geeta",        "blue",        "red",        "shyam"     ); shuffle($a);print_r($a); ?>
Output: 
Array
(
    [0] => red
    [1] => geeta
    [2] => ram
    [3] => shyam
    [4] => blue
)
Reference: http://php.net/manual/en/function.shuffle.php 
nidhi_biet
arorakashish0911
anikakapoor
PHP-array
PHP-function
PHP
Web Technologies
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Data Binding with LiveData in Android

07 Oct, 2021
Prerequisite:
DataBinding
LiveData and ViewModel
So, Why we are using Data binding with LiveData? Actually, If we want our views to directly communicate with ViewModel (Data source), we can do that simply without using LiveData. But if data changes in ViewModel it won’t reflect its View. This is where we can take the help of LiveData, to automatically update the view whenever there is any change in data.
We need to declare the data in ViewModel as LiveData, We can use MutableLiveData ( most commonly ) it is just a class that extends LiveData.
Kotlin
class MainViewModel : ViewModel() {    var text = MutableLiveData(" Welcome to my application ")      fun updateText() {        text.value = " Text is updated successfully "    }}
  
We can use a method value() to update the data (it must be called from the main thread if you are calling from the background thread you need to use postValue( ) method ).
Normally we use observer( ) to binds the view and LiveData, but here as we are using Data Binding in which we have directly bind the views with data we don’t need an observer( ).
One thing to note is that as we need to give LifeCycleOwner to LiveData we were passing the LifeCycleOwner to observer( ).
But Here we can also pass the LifeCycleOwner to Binding object using lifecycleOwner( ) method.
Kotlin
class MainActivity : AppCompatActivity() {      lateinit var binding: ActivityMainBinding    lateinit var mainViewModel: MainViewModel      override fun onCreate(savedInstanceState: Bundle?) {        super.onCreate(savedInstanceState)        binding = DataBindingUtil.setContentView(this, R.layout.activity_main)          // Creating MainViewModel object        mainViewModel = MainViewModel()          // Binding mainViewModel variable         // with MainViewModel object        binding.mainViewModel = mainViewModel                 // passing LifeCycleOwner to binding object        binding.lifecycleOwner = this     }}
Output:
Text view is initialized with some text.
 
After clicking the UPDATE TEXT button.
As we can see that when the app is open the Text View is set by default.
And when we click the UPDATE TEXT button the Text View is updated.
So our application is ready and working properly.
We have implemented Data Binding using ViewModel and LiveData.
anikakapoor
Android
Kotlin
Android
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Add Views Dynamically and Store Data in Arraylist in Android?
Android SDK and it's Components
How to Communicate Between Fragments in Android?
Flutter - Custom Bottom Navigation Bar
Retrofit with Kotlin Coroutine in Android
How to Add Views Dynamically and Store Data in Arraylist in Android?
Android UI Layouts
Kotlin Array
How to Communicate Between Fragments in Android?
Retrofit with Kotlin Coroutine in Android
What is the use of the @ symbol in PHP?

17 Oct, 2018
The at sign (@) is used as error control operator in PHP. When an expression is prepended with the @ sign, error messages that might be generated by that expression will be ignored. If the track_errors feature is enabled, an error message generated by the expression and it will be saved in the variable $php_errormsg. This variable will be overwritten on each error.
Program 1:
<?php  // File error $file_name = @file ('non_existent_file') or    die ("Failed in opening the file: error: '$errormsg'");  // It is used for expression$value = @$cache[$key];  // It will not display notice if the index $key doesn't exist.  ?>
RunTime Error:
PHP Notice:  Undefined variable: errormsg in /home/fe74424b34d1adf15aa38a0746a79bed.php on line 5
Output:
Failed in opening the file: error: ''
Program 2:
<?php  // Statement 1$result= $hello['123']  // Statement 2$result= @$hello['123']?>
It will execute only statement 1 and display the notice message
PHP Notice:  Undefined variable: hello.
Note: The use of @ is very bad programming practice as it does not make error disappear, it just hides them, and it makes debugging a lot worse since we can’t see what’s actually wrong with our code.
References: Error Control Operators
Picked
PHP
Web Technologies
PHP
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to fetch data from localserver database and display on HTML table using PHP ?
Difference between HTTP GET and POST Methods
Different ways for passing data to view in Laravel
PHP | file_exists( ) Function
PHP | Ternary Operator
Installation of Node.js on Linux
Top 10 Projects For Beginners To Practice HTML and CSS Skills
Difference between var, let and const keywords in JavaScript
How to insert spaces/tabs in text using HTML/CSS?
How to fetch data from an API in ReactJS ?
Program to count number of paths with cost k from start to end point in Python

Suppose we have a 2d binary matrix and another value k. Now starting from the top-left cell, we have to go to the bottom right cell. In one step, we can only go down, or right. Now the score of a path is the sum of the values on the cells on the path. We have to find the number of paths from the start cell to end cell with score k. If there are huge possible ways then return result mod 10^9+7.
So, if the input is like
K = 2, then the output will be 4, as the paths with score 2 are [R,R,D,D], [D,R,R,D], [D,D,R,R], [D,R,D,R] here D is down and R is right.
To solve this, we will follow these steps −
deno := 10^9 + 7
deno := 10^9 + 7
m := row count of matrix, n := column count of matrix
m := row count of matrix, n := column count of matrix
Define a function dfs() . This will take i, j, pts
Define a function dfs() . This will take i, j, pts
if i >= m or j >= n, thenreturn 0
if i >= m or j >= n, then
return 0
return 0
pts := pts + matrix[i, j]
pts := pts + matrix[i, j]
if i is same as m - 1 and j is same as n - 1, thenreturn 1 when pts is same as k otherwise 0
if i is same as m - 1 and j is same as n - 1, then
return 1 when pts is same as k otherwise 0
return 1 when pts is same as k otherwise 0
return dfs(i + 1, j, pts) + dfs(i, j + 1, pts)
return dfs(i + 1, j, pts) + dfs(i, j + 1, pts)
From the main method do the following −
From the main method do the following −
return dfs(0, 0, 0) mod deno
return dfs(0, 0, 0) mod deno
Let us see the following implementation to get better understanding −
 Live Demo
class Solution:
   def solve(self, matrix, k):
      m, n = len(matrix), len(matrix[0])
      def dfs(i=0, j=0, pts=0):
         if i >= m or j >= n:
            return 0
         pts += matrix[i][j]
         if i == m - 1 and j == n - 1:
            return int(pts == k)
         return dfs(i + 1, j, pts) + dfs(i, j + 1, pts)
      return dfs() % (10 ** 9 + 7)

ob = Solution()
matrix = [
   [0, 0, 1],
   [1, 0, 1],
   [0, 1, 0]
]
k = 2
print(ob.solve(matrix, k))
[
   [0, 0, 1],
   [1, 0, 1],
   [0, 1, 0]
], 2
4