The main purpose of Objective-C programming language is to add object
orientation to the C programming language and classes are the central
feature of Objective-C that support object-oriented programming and are
often called user-defined types.
পৃষ্ঠাসমূহ
Labels
.
Search Your Article
Total Pageviews
Saturday, February 4, 2017
Objective-C Inheritance
One of the most important concepts in object-oriented programming is
that of inheritance. Inheritance allows us to define a class in terms of
another class which makes it easier to create and maintain an
application. This also provides an opportunity to reuse the code
functionality and fast implementation time.
Objective-C Polymorphism
The word polymorphism means having many forms. Typically,
polymorphism occurs when there is a hierarchy of classes and they are
related by inheritance.
Objective-C polymorphism means that a call to a member function will cause a different function to be executed depending on the type of object that invokes the function.
Objective-C polymorphism means that a call to a member function will cause a different function to be executed depending on the type of object that invokes the function.
Objective-C Data Encapsulation
All Objective-C programs are composed of the following two fundamental elements:
- Program statements (code): This is the part of a program that performs actions and they are called methods.
- Program data: The data is the information of the program which is affected by the program functions.
Objective-C Categories
Sometimes, you may find that you wish to extend an existing class by
adding behavior that is useful only in certain situations. In order add
such extension to existing classes, Objective-C provides categories and extensions.
Objective-C Posing
Before starting about Posing in Objective-C, I would like to bring to
your notice that Posing was declared deprecated in Mac OS X 10.5 and
it's not available for use thereafter. So for those who are not
concerned about these deprecated methods can skip this chapter.
Objective-C Extensions
A class extension bears some similarity to a category, but it can
only be added to a class for which you have the source code at compile
time (the class is compiled at the same time as the class extension).
The methods declared by a class extension are implemented in the implementation block for the original class, so you can't,
The methods declared by a class extension are implemented in the implementation block for the original class, so you can't,
Objective-C Protocols
Objective-C allows you to define protocols, which declare the methods
expected to be used for a particular situation. Protocols are
implemented in the classes conforming to the protocol.
A simple example would be a network URL handling class, it will have a protocol with methods like processCompleted delegate method that intimates the calling class once the network URL fetching operation is over.
A simple example would be a network URL handling class, it will have a protocol with methods like processCompleted delegate method that intimates the calling class once the network URL fetching operation is over.
Objective-C Dynamic Binding
Dynamic binding is determining the method to invoke at runtime
instead of at compile time. Dynamic binding is also referred to as late
binding.
In Objective-C, all methods are resolved dynamically at runtime. The exact code executed is determined by both the method name (the selector) and the receiving object.
In Objective-C, all methods are resolved dynamically at runtime. The exact code executed is determined by both the method name (the selector) and the receiving object.
Objective-C Composite Objects
We can create subclass within a class cluster that defines a class
that embeds within it an object. These class objects are composite
objects.
So you might be wondering what's a class cluster. So we will first see what's a class cluster.
So you might be wondering what's a class cluster. So we will first see what's a class cluster.
Obj-C Foundation Framework
If you refer Apple documentation, you can see the details of Foundation framework as given below.
The Foundation framework defines a base layer of Objective-C classes. In addition to providing a set of useful primitive object classes, it introduces several paradigms that define functionality not covered by the Objective-C language. The Foundation framework is designed with these goals in mind:
The Foundation framework defines a base layer of Objective-C classes. In addition to providing a set of useful primitive object classes, it introduces several paradigms that define functionality not covered by the Objective-C language. The Foundation framework is designed with these goals in mind:
Objective-C Fast Enumeration
Fast enumeration is an Objective-C's feature that helps in
enumerating through a collection. So in order to know about fast
enumeration, we need know about collection first which will be explained
in the following section.
Obj-C Memory Management
Memory management is one of the most important process in any
programming language. It is the process by which the memory of objects
are allocated when they are required and deallocated when they are no
longer required.
Objective-C Quick Guide
Objective-C Overview
Objective-C is general-purpose language that is developed on top of C Programming language by adding features of Small Talk programming language making it an object-oriented language. It is primarily used in developing iOS and Mac OS X operating systems as well as its applications.Objective-C - Useful Resources
The following resources contain additional information on Objective
C. Please use them to get more in-depth knowledge on this topic.
Discuss Objective-C
Objective-C is a general-purpose, object-oriented programming
language that adds Smalltalk-style messaging to the C programming
language. This is the main programming language used by Apple for the OS
X and iOS operating systems and their respective APIs, Cocoa and Cocoa
Touch.
Node.js - Introduction
What is Node.js?
Node.js is a server-side platform built on Google Chrome's JavaScript Engine (V8 Engine). Node.js was developed by Ryan Dahl in 2009 and its latest version is v0.10.36. The definition of Node.js as supplied by its official documentation is as follows −Node.js - Environment Setup
Try it Option Online
You really do not need to set up your own environment to start learning Node.js. Reason is very simple, we already have set up Node.js environment online, so that you can execute all the available examples online at the same time when you are doing your theory work.
Node.js - First Application
Before creating an actual "Hello, World!" application using Node.js,
let us see the components of a Node.js application. A Node.js
application consists of the following three important components −
Node.js - REPL Terminal
REPL stands for Read Eval Print Loop and it represents a computer
environment like a Windows console or Unix/Linux shell where a command
is entered and the system responds with an output in an interactive
mode. Node.js or Node comes bundled with a REPL environment. It performs the following tasks −
Node.js - NPM
Node Package Manager (NPM) provides two main functionalities −
- Online repositories for node.js packages/modules which are searchable on search.nodejs.org
- Command line utility to install Node.js packages, do version management and dependency management of Node.js packages.
Node.js - Callbacks Concept
What is Callback?
Callback is an asynchronous equivalent for a function. A callback function is called at the completion of a given task. Node makes heavy use of callbacks. All the APIs of Node are written in such a way that they support callbacks.Node.js - Event Loop
Node.js is a single-threaded application, but it can support concurrency via the concept of event and callbacks. Every API of Node.js is asynchronous and being single-threaded, they use async function calls
to maintain concurrency.
Node.js - Event Emitter
Many objects in a Node emit events, for example, a net.Server emits
an event each time a peer connects to it, an fs.readStream emits an
event when the file is opened. All objects which emit events are the
instances of events.EventEmitter.
Node.js - Buffers
Pure JavaScript is Unicode friendly, but it is not so for binary
data. While dealing with TCP streams or the file system, it's necessary
to handle octet streams. Node provides Buffer class which provides
instances to store raw data similar to an array of integers but
corresponds to a raw memory allocation outside the V8 heap.
Node.js - Streams
What are Streams?
Streams are objects that let you read data from a source or write data to a destination in continuous fashion. In Node.js, there are four types of streams −Node.js - File System
Node implements File I/O using simple wrappers around standard POSIX
functions. The Node File System (fs) module can be imported using the
following syntax −
var fs = require("fs")
Node.js - Global Objects
Node.js global objects are global in nature and they are available in
all modules. We do not need to include these objects in our
application, rather we can use them directly. These objects are modules,
functions, strings and object itself as explained below.
Node.js - Utility Modules
There are several utility modules available in Node.js module
library. These modules are very common and are frequently used while
developing any Node based application.
Node.js - Web Module
What is a Web Server?
A Web Server is a software application which handles HTTP requests sent by the HTTP client, like web browsers, and returns web pages in response to the clients. Web servers usually deliver html documents along with images, style sheets, and scripts.Node.js - Express Framework
Express Overview
Express is a minimal and flexible Node.js web application framework that provides a robust set of features to develop web and mobile applications. It facilitates the rapid development of Node based Web applications. Following are some of the core features of Express framework −Node.js - RESTful API
What is REST architecture?
REST stands for REpresentational State Transfer. REST is web standards based architecture and uses HTTP Protocol. It revolves around resource where every component is a resource and a resource is accessed by a common interface using HTTP standard methods. REST was first introduced by Roy Fielding in 2000.Node.js - Scaling Application
Node.js runs in a single-thread mode, but it uses an event-driven
paradigm to handle concurrency. It also facilitates creation of child
processes to leverage parallel processing on multi-core CPU based
systems.
Child processes always have three streams child.stdin, child.stdout, and child.stderr which may be shared with the stdio streams of the parent process.
Child processes always have three streams child.stdin, child.stdout, and child.stderr which may be shared with the stdio streams of the parent process.
Node.js - Packaging
JXcore, which is an open source project, introduces a unique
feature for packaging and encryption of source files and other assets
into JX packages.
Consider you have a large project consisting of many files. JXcore can pack them all into a single file to simplify the distribution. This chapter provides a quick overview of the whole process starting from installing JXcore.
Consider you have a large project consisting of many files. JXcore can pack them all into a single file to simplify the distribution. This chapter provides a quick overview of the whole process starting from installing JXcore.
Node.js - Quick Guide
Node.js - Introduction
What is Node.js?
Node.js is a server-side platform built on Google Chrome's JavaScript Engine (V8 Engine). Node.js was developed by Ryan Dahl in 2009 and its latest version is v0.10.36. The definition of Node.js as supplied by its official documentation is as follows −Node.js - Useful Resources
The following resources contain additional information on Node.js. Please use them to get more in-depth knowledge on this.
Discuss Node.js
Node.js is a very powerful JavaScript-based framework/platform built
on Google Chrome's JavaScript V8 Engine. It is used to develop I/O
intensive web applications like video streaming sites, single-page
applications, and other web applications. Node.js is open source,
completely free, and used by thousands of developers around the world.
MATLAB - Overview
MATLAB (matrix laboratory) is a fourth-generation high-level
programming language and interactive environment for numerical
computation, visualization and programming.
MATLAB - Environment Setup
Try it Option Online
You really do not need to set up your own environment to start learning MATLAB Octave. Reason is very simple, we already have set up MATLAB Octave environment online, so that you can execute all the available examples online at the same time when you are doing your theory work.
MATLAB - Basic Syntax
MATLAB environment behaves like a super-complex calculator. You can enter commands at the >> command prompt.
MATLAB is an interpreted environment. In other words, you give a command and MATLAB executes it right away.
MATLAB is an interpreted environment. In other words, you give a command and MATLAB executes it right away.
MATLAB - Variables
In MATLAB environment, every variable is an array or matrix.
You can assign variables in a simple way. For example,
You can assign variables in a simple way. For example,
x = 3 % defining x and initializing it with a valueMATLAB will execute the above statement and return the following result −
x = 3
MATLAB - Commands
MATLAB is an interactive program for numerical computation and data
visualization. You can enter a command by typing it at the MATLAB prompt
'>>' on the Command Window.
In this section, we will provide lists of commonly used general MATLAB commands.
In this section, we will provide lists of commonly used general MATLAB commands.
MATLAB - M-Files
So far, we have used MATLAB environment as a calculator. However,
MATLAB is also a powerful programming language, as well as an
interactive computational environment.
In previous chapters, you have learned how to enter commands from the MATLAB command prompt.
In previous chapters, you have learned how to enter commands from the MATLAB command prompt.
MATLAB - Data Types
MATLAB does not require any type declaration or dimension statements.
Whenever MATLAB encounters a new variable name, it creates the variable
and allocates appropriate memory space.
MATLAB - Operators
An operator is a symbol that tells the compiler to perform specific
mathematical or logical manipulations. MATLAB is designed to operate
primarily on whole matrices and arrays. Therefore, operators in MATLAB
work both on scalar and non-scalar data. MATLAB allows the following
types of elementary operations −
MATLAB - Decision Making
Decision making structures require that the programmer should specify
one or more conditions to be evaluated or tested by the program, along
with a statement or statements to be executed if the condition is
determined to be true, and optionally, other statements to be executed
if the condition is determined to be false.
MATLAB - Matrix
A matrix is a two-dimensional array of numbers.
In MATLAB, you create a matrix by entering elements in each row as comma or space delimited numbers and using semicolons to mark the end of each row.
For example, let us create a 4-by-5 matrix a −
In MATLAB, you create a matrix by entering elements in each row as comma or space delimited numbers and using semicolons to mark the end of each row.
For example, let us create a 4-by-5 matrix a −
MATLAB - Loop Types
There may be a situation when you need to execute a block of code
several number of times. In general, statements are executed
sequentially. The first statement in a function is executed first,
followed by the second, and so on.
MATLAB - Vectors
A vector is a one-dimensional array of numbers. MATLAB allows creating two types of vectors −
- Row vectors
- Column vectors
MATLAB - Arrays
All variables of all data types in MATLAB are multidimensional
arrays. A vector is a one-dimensional array and a matrix is a
two-dimensional array.
We have already discussed vectors and matrices. In this chapter, we will discuss multidimensional arrays. However, before that, let us discuss some special types of arrays.
We have already discussed vectors and matrices. In this chapter, we will discuss multidimensional arrays. However, before that, let us discuss some special types of arrays.
MATLAB - Colon Notation
The colon(:) is one of the most useful operator in MATLAB. It is used to create vectors, subscript arrays, and specify for iterations.
If you want to create a row vector, containing integers from 1 to 10, you write −
If you want to create a row vector, containing integers from 1 to 10, you write −
MATLAB - Numbers
MATLAB supports various numeric classes that include signed and
unsigned integers and single-precision and double-precision
floating-point numbers. By default, MATLAB stores all numeric values as
double-precision floating point numbers.
MATLAB - Strings
Creating a character string is quite simple in MATLAB. In fact, we
have used it many times. For example, you type the following in the
command prompt −
MATLAB - Functions
A function is a group of statements that together perform a task. In
MATLAB, functions are defined in separate files. The name of the file
and of the function should be the same.
MATLAB - Data Import
Importing data in MATLAB means loading data from an external file. The importdata function allows loading various data files of different formats. It has the following five forms −
MATLAB - Data Output
Data export (or output) in MATLAB means to write into files. MATLAB
allows you to use your data in another application that reads ASCII
files. For this, MATLAB provides several data export options.
You can create the following type of files:
You can create the following type of files:
MATLAB - Plotting
To plot the graph of a function, you need to take the following steps −
- Define x, by specifying the range of values for the variable x, for which the function is to be plotted
- Define the function, y = f(x)
- Call the plot command, as plot(x, y)
MATLAB - Graphics
This chapter will continue exploring the plotting and graphics capabilities of MATLAB. We will discuss −
- Drawing bar charts
- Drawing contours
- Three dimensional plots
MATLAB - Algebra
So far, we have seen that all the examples work in MATLAB as well as
its GNU, alternatively called Octave. But for solving basic algebraic
equations, both MATLAB and Octave are little different, so we will try
to cover MATLAB and Octave in separate sections.
MATLAB - Calculus
MATLAB provides various ways for solving problems of differential and
integral calculus, solving differential equations of any degree and
calculation of limits. Best of all, you can easily plot the graphs of
complex functions and check maxima, minima and other stationery points
on a graph by solving the original function, as well as its derivative.
MATLAB - Differential
MATLAB provides the diff command for computing symbolic
derivatives. In its simplest form, you pass the function you want to
differentiate to diff command as an argument.
For example, let us compute the derivative of the function f(t) = 3t2 + 2t-2
For example, let us compute the derivative of the function f(t) = 3t2 + 2t-2
MATLAB - Integration
Integration deals with two essentially different types of problems.
- In the first type, derivative of a function is given and we want
to find the function. Therefore, we basically reverse the process of
differentiation. This reverse process is known as anti-differentiation,
or finding the primitive function, or finding an indefinite integral.
MATLAB - Polynomials
MATLAB represents polynomials as row vectors containing coefficients
ordered by descending powers. For example, the equation P(x) = x4 + 7x3 - 5x + 9 could be represented as −
p = [1 7 0 -5 9];
p = [1 7 0 -5 9];
MATLAB - Transforms
MATLAB provides command for working with transforms, such as the Laplace and Fourier transforms. Transforms are used in science and engineering as a tool for simplifying analysis and look at data from another angle.
MATLAB - GNU Octave Tutorial
GNU Octave is a high-level programming language like MATLAB and it is mostly compatible with MATLAB. It is also used for numerical computations.
Octave has the following common features with MATLAB −
Octave has the following common features with MATLAB −
MATLAB - Simulink
Simulink is a simulation and model-based design environment for dynamic and embedded systems, integrated with MATLAB. Simulink, also developed by MathWorks, is a data flow graphical programming language tool for modelling, simulating and analyzing multi-domain dynamic systems.
MATLAB - Quick Guide
MATLAB - Overview
MATLAB (matrix laboratory) is a fourth-generation high-level programming language and interactive environment for numerical computation, visualization and programming.MATLAB is developed by MathWorks.
MATLAB - USeful Resources
The following resources contain additional information on MATLAB. Please use them to get more in-depth knowledge on this topic.
Discuss MATLAB
MATLAB is a programming language developed by MathWorks. It started
out as a matrix programming language where linear algebra programming
was simple. It can be run both under interactive sessions and as a batch
job.
Friday, February 3, 2017
LISP - Overview
John McCarthy invented LISP in 1958, shortly after the development of
FORTRAN. It was first implement by Steve Russell on an IBM 704
computer.
LISP - Environment Setup
Try it Option Online
You really do not need to set up your own environment to start learning LISP programming language. Reason is very simple, we already have set up Lisp Programming environment online, so that you can execute all the available examples online at the same time when you are doing your theory work.
LISP - Program Structure
LISP expressions are called symbolic expressions or s-expressions.
The s-expressions are composed of three valid objects, atoms, lists and
strings.
Any s-expression is a valid program.
Any s-expression is a valid program.
LISP - Basic Syntax
Basic Building Blocks in LISP
LISP programs are made up of three basic building blocks:- atom
- list
- string
LISP - Data Types
In LISP, variables are not typed, but data objects are.
LISP data types can be categorized as.
LISP data types can be categorized as.
- Scalar types - for example, number types, characters, symbols etc.
- Data structures - for example, lists, vectors, bit-vectors, and strings.
LISP - Macros
Macros allow you to extend the syntax of standard LISP.
Technically, a macro is a function that takes an s-expression as arguments and returns a LISP form, which is then evaluated.
Technically, a macro is a function that takes an s-expression as arguments and returns a LISP form, which is then evaluated.
LISP - Variables
In LISP, each variable is represented by a symbol. The variable's name is the name of the symbol and it is stored in the storage cell of the symbol.
LISP - Constants
In LISP, constants are variables that never change their values during program execution. Constants are declared using the defconstant construct.
LISP - Operators
An operator is a symbol that tells the compiler to perform specific
mathematical or logical manipulations. LISP allows numerous operations
on data, supported by various functions, macros and other constructs.
The operations allowed on data could be categorized as:
The operations allowed on data could be categorized as:
LISP - Decision Making
Decision making structures require that the programmer specify one or
more conditions to be evaluated or tested by the program, along with a
statement or statements to be executed if the condition is determined to
be true, and optionally, other statements to be executed if the
condition is determined to be false.
LISP - Loops
There may be a situation, when you need to execute a block of code
numbers of times. A loop statement allows us to execute a statement or
group of statements multiple times and following is the general form of a
loop statement in most of the programming languages.
LISP - Functions
A function is a group of statements that together perform a task.
You can divide up your code into separate functions. How you divide up your code among different functions is up to you, but logically the division usually is so each function performs a specific task.
You can divide up your code into separate functions. How you divide up your code among different functions is up to you, but logically the division usually is so each function performs a specific task.
LISP - Predicates
Predicates are functions that test their arguments for some specific
conditions and returns nil if the condition is false, or some non-nil
value is the condition is true.
The following table shows some of the most commonly used predicates:
The following table shows some of the most commonly used predicates:
LISP - Numbers
Common Lisp defines several kinds of numbers. The number data type includes various kinds of numbers supported by LISP.
The number types supported by LISP are:
The number types supported by LISP are:
LISP - Characters
In LISP, characters are represented as data objects of type character.
You can denote a character object preceding #\ before the character itself. For example, #\a means the character a.
You can denote a character object preceding #\ before the character itself. For example, #\a means the character a.
LISP - Arrays
LISP allows you to define single or multiple-dimension arrays using the make-array function. An array can store any LISP object as its elements.
All arrays consist of contiguous memory locations. The lowest address corresponds to the first element and the highest address to the last element.
All arrays consist of contiguous memory locations. The lowest address corresponds to the first element and the highest address to the last element.
LISP - Strings
Strings in Common Lisp are vectors, i.e., one-dimensional array of characters.
String literals are enclosed in double quotes. Any character supported by the character set can be enclosed within double quotes to make a string, except the double quote character (") and the escape character (\). However, you can include these by escaping them with a backslash (\).
String literals are enclosed in double quotes. Any character supported by the character set can be enclosed within double quotes to make a string, except the double quote character (") and the escape character (\). However, you can include these by escaping them with a backslash (\).
LISP - Sequences
Sequence is an abstract data type in LISP. Vectors and lists are the
two concrete subtypes of this data type. All the functionalities defined
on sequence data type are actually applied on all vectors and list
types.
In this section, we will discuss most commonly used functions on sequences.
In this section, we will discuss most commonly used functions on sequences.
LISP - Lists
Lists had been the most important and the primary composite data
structure in traditional LISP. Present day's Common LISP provides other
data structures like, vector, hash table, classes or structures.
Lists are single linked lists. In LISP, lists are constructed as a chain of a simple record structure named cons linked together.
Lists are single linked lists. In LISP, lists are constructed as a chain of a simple record structure named cons linked together.
LISP - Symbols
In LISP, a symbol is a name that represents data objects and interestingly it is also a data object.
What makes symbols special is that they have a component called the property list, or plist.
What makes symbols special is that they have a component called the property list, or plist.
LISP - Vectors
Vectors are one-dimensional arrays, therefore a subtype of array.
Vectors and lists are collectively called sequences. Therefore all
sequence generic functions and array functions we have discussed so far,
work on vectors.
LISP - Set
Common Lisp does not provide a set data type. However, it provides
number of functions that allows set operations to be performed on a
list.
You can add, remove, and search for items in a list, based on various criteria. You can also perform various set operations like: union, intersection, and set difference.
You can add, remove, and search for items in a list, based on various criteria. You can also perform various set operations like: union, intersection, and set difference.
LISP - Tree
You can build tree data structures from cons cells, as lists of lists.
To implement tree structures, you will have to design functionalities that would traverse through the cons cells, in specific order, for example, pre-order, in-order, and post-order for binary trees.
To implement tree structures, you will have to design functionalities that would traverse through the cons cells, in specific order, for example, pre-order, in-order, and post-order for binary trees.
LISP - Hash Table
The hash table data structure represents a collection of key-and-value pairs that are organized based on the hash code of the key. It uses the key to access the elements in the collection.
LISP - Input & Output
Common LISP provides numerous input-output functions. We have already
used the format function, and print function for output. In this
section, we will look into some of the most commonly used input-output
functions provided in LISP.
LISP - File I/O
We have discussed about how standard input and output is handled by
common LISP. All these functions work for reading from and writing into
text and binary files too. Only difference is in this case the stream we
use is not standard input or output, but a stream created for the
specific purpose of writing into or reading from files.
LISP - Structures
Structures are one of the user-defined data type, which allows you to combine data items of different kinds.
Structures are used to represent a record. Suppose you want to keep track of your books in a library. You might want to track the following attributes about each book:
Structures are used to represent a record. Suppose you want to keep track of your books in a library. You might want to track the following attributes about each book:
LISP - Packages
In general term of programming languages, a package is designed for
providing a way to keep one set of names separate from another. The
symbols declared in one package will not conflict with the same symbols
declared in another. This way packages reduce the naming conflicts
between independent code modules.
LISP - Error Handling
In Common LISP terminology, exceptions are called conditions.
In fact, conditions are more general than exceptions in traditional programming languages, because a condition represents any occurrence, error, or not, which might affect various levels of function call stack.
In fact, conditions are more general than exceptions in traditional programming languages, because a condition represents any occurrence, error, or not, which might affect various levels of function call stack.
LISP - CLOS
Common LISP predated the advance of object-oriented programming by
couple of decades. However, it object-orientation was incorporated into
it at a later stage.
LISP - Quick Guide
LISP - Overview
John McCarthy invented LISP in 1958, shortly after the development of FORTRAN. It was first implement by Steve Russell on an IBM 704 computer.It is particularly suitable for Artificial Intelligence programs, as it processes symbolic information effectively.
LISP - Useful Resources
The following resources contain additional information on LISP. Please use them to get more in-depth knowledge on this topic.
Discuss LISP
Lisp is the second-oldest high-level programming language after
Fortran and has changed a great deal since its early days, and a number
of dialects have existed over its history. Today, the most widely known
general-purpose Lisp dialects are Common Lisp and Scheme.
Small & Simple Programs in C
Let's first start with very small & simple programs to get basic
idea of C programming code structure. We shall get the basic idea of
variable declaration, scanning and printing etc.
Loop Examples in C
This segment is designed to give the learner an enhanced view of how
loops work in c langauges. We shall see simple loops like for, while
and do-while, along with nested loops.
Patterns Examples in C
This section is full of examples that uses nested loops in a
controlled manner. We may see that the outer loop is controlling the
inner one etc. We have taken the simplest examples which are very
common too.
Array Example Programs in C
Array is a collection of homogenous data, arranged in sequential
format. Learning the concept of arrays in C is very important as it is
the basic data structure. Here, in this section, we shall look into
some very useful array programs to give you insight of how C programming
language deals with arrays.
String Programs in C
Strings are actually one-dimensional array of characters terminated by a null character '\0'. Thus a null-terminated string contains the characters that comprise the string followed by a null.
Mathematical Programs in C
This section has been developed to introduce some common mathematical problems that can be solved using c programming language.
Linked List Programs in C
A linked-list is a sequence of data structures which are connected together via links.
Linked List is a sequence of links which contains items. Each link contains a connection to another link. Linked list the second most used data structure after array.
Linked List is a sequence of links which contains items. Each link contains a connection to another link. Linked list the second most used data structure after array.
Learn C By Examples - Quick Guide
Small & Simple Programs in C
Let's first start with very small & small programs to get basic idea of C programming code structure. We shall get the basic idea of variable declaration, scanning and printing etc.Learn C By Examples - Useful Resources
The following resources contain additional information on Learn C By
Examples. Please use them to get more in-depth knowledge on this topic.
Discuss Learn C By Examples
C is a general-purpose, procedural, imperative computer programming
language developed in 1972 by Dennis M. Ritchie at the Bell Telephone
Laboratories to develop the UNIX operating system. C is the most widely
used computer language. It keeps fluctuating at number one scale of
popularity along with Java programming language, which is also equally
popular and most widely used among modern software programmers.
JCL - Overview
When to use JCL
JCL is used in a mainframe environment to act as a communication between a program (Example: COBOL, Assembler or PL/I) and the operating system. In a mainframe environment, programs can be executed in batch and online mode.JCL - Environment Setup
Installing JCL on Windows/Linux
There are many Free Mainframe Emulators available for Windows which can be used to write and learn sample JCLs.One such emulator is Hercules, which can be easily installed in Windows by following few simple steps given below:
JCL - JOB Statement
JOB Statement is the first control statement in a JCL. This gives the
identity of the job to the Operating System (OS), in the spool and in
the scheduler. The parameters in the JOB statement help the Operating
Systems in allocating the right scheduler, required CPU time and issuing
notifications to the user.
JCL - EXEC Statement
Each JCL can be made of many job steps. Each job step can execute a
program directly or can call a procedure, which in turn executes one or
more programs (job steps). The statement, which holds the job step
program/procedure information is the EXEC statement.
JCL - DD Statement
Datasets are mainframe files with records organised in a specific
format. Datasets are stored on the Direct Access Storage Device (DASD)
or Tapes of the mainframe and are basic data storage areas. If these
data are required to be used/created in a batch program, then the file
(i.e., dataset) physical name along with the file format and
organisation are coded in a JCL.
JCL - Base Library
Base Library is the Partitioned Dataset (PDS), which holds the
load modules of the program to be executed in the JCL or the catalogued
procedure, which is called in the program. Base libraries can be
specified for the whole JCL in a JOBLIB library or for a particular job step in a STEPLIB statement.
JCL - Procedures
The JCL Procedures are set of statements inside a JCL grouped
together to perform a particular function. Usually, the fixed part of
the JCL is coded in a procedure. The varying part of the Job is coded
within the JCL.
JCL - Conditional Processing
The Job Entry System uses two approaches to perform conditional
processing in a JCL. When a job completes, a return code is set based on
the status of execution. The return code can be a number between 0
(successful execution) to 4095 (non-zero shows error condition). The
most common conventional values are:
JCL - Defining Datasets
A dataset name specifies the name of a file and it is denoted by DSN
in JCL. The DSN parameter refers to the physical dataset name of a newly
created or existing dataset. The DSN value can be made up of sub-names
each of 1 to 8 characters length, separated by periods and of total
length of 44 characters
Input-Output Methods
Any batch program executed through a JCL requires data input, which
is processed and an output is created. There are different methods of
feeding input to the program and writing output received from a JCL. In
batch mode, there is no user interaction required but input and output
devices and required organisation are defined in JCL and submitted.
Running COBOL Programs using JCL
Compiling COBOL Programs
In order to execute a COBOL program in batch mode using JCL, the program needs to be compiled and a load module is created with all the sub-programs. The JCL uses the load module and not the actual program at the time of execution.JCL - Utility Programs
IBM Dataset Utilities
Utility programs are pre-written programs, widely used in mainframes by system programmers and application developers to achieve day-to-day requirements, organising and maintaining data. A few of them are listed below with their functionality:JCL - Basic Sort Tricks
The day-to-day application requirements in a corporate world that can be achieved using Utility Programs are illustrated below:
JCL Questions and Answers
JCL Questions and Answers has been designed with a special intention of helping students and professionals preparing for various Certification Exams and Job Interviews.
This section provides a useful collection of sample Interview Questions
and Multiple Choice Questions (MCQs) and their answers with
appropriate explanations.
JCL - Quick Guide
JCL - Overview
When to use JCL
JCL is used in a mainframe environment to act as a communication between a program (Example: COBOL, Assembler or PL/I) and the operating system. In a mainframe environment, programs can be executed in batch and online mode.JCL - Useful Resources
If you want to list down your website, book or any other resource on
this page, then please contact at webmaster@tutorialspoint.com.
Discuss JCL
Job Control Language (JCL) is the command language of Multiple Virtual
Storage (MVS), which is the commonly used Operating System in the IBM
Mainframe computers. JCL identifies the program to be executed, the
inputs that are required and location of the input/output and informs
the Operating System through Job control Statements. In mainframe
environment, programs can be executed in batch and online modes. JCL is
used for submitting a program for execution in batch mode.
Java BeanUtils - Overview
Description
The Java BeanUtils are the components of the Apache Commons which are derived from JavaAPI and provides component architecture for the Java language. The Java BeanUtils design patterns uses utility classes that helps to get and set the property values on Java classes for retrieving and defining the bean properties.Java BeanUtils - Background
Description
The standard JavaBeans of Java language can be used to access the property values of beans using the proper getter methods. The Java language supplies the java.beans.Introspector class to inspect a Java class at runtime.Java BeanUtils - Basic Property Access
Description
You can access the basic properties by using the following ways:- Simple Property
- Indexed Property
- Mapped Property
Java BeanUtils - Nested Property Access
Description
You can access the value of nested property of the bean by concatenating the property names of the access path by using "." separators.You can get and set the values of Nested property by using the below methods:
Java BeanUtils - Customizing Introspection
Description
The introspection tool can be used to learn about the properties and operations provided by your class. BeanUtils package is depending on JavaBeans specification that determines the available properties for a particular bean class.Java BeanUtils - Suppressing Properties
Description
You can suppress the specific properties by using the bean introspection mechanism. The specialized BeanIntrospector interface is implemented by the type called SuppressPropertiesBeanIntrospector which suppresses the special class properties of Java beans.Java BeanUtils - Background (DynaBeans)
Description
You can give dynamic property access on the existing JavaBean classes without altering with the help of PropertyUtils class. The dynamically calculated property values as JavaBean can also represented by using dynamic property access without writing a Java class to render these properties.Java BeanUtils - Basic DynaBeans
Description
The implementation of BasicDynaBean and BasicDynaClass specifies the capacity of dynamic property to provide the set of properties dynamically. You can start with DynaClass to establish the set of properties. A newInstance() method will create a new DynaBean instances to DynaClass and occupy its initial values as shown in the below example.Java BeanUtils - ResultSetDynaClass
Description
The ResultSet can be wrapped in the DynaBeans by using the ResultSetDynaClass which renders the results of SQL query as series of DynaBeans. The most commonly used collection is java.sql.ResultSet which is returned when JDBC driver uses SQL SELECT statement.Java BeanUtils - RowSetDynaClass
Description
The RowSetDynaClass copies the undisclosed data in the DynaBeans memory while creating an instance which displays the result and using this class, you can close the ResultSet data before proceeding the actual data that was returned.Java BeanUtils - WrapDynaBean
Description
As we have seen in the previous chapters, DynaBeans APIs provides get() and set() methods to access simple, indexed and mapped properties of DynaBeans dynamically.Java BeanUtils - Lazy DynaBeans
Description
Lazy DynaBeans is an implementation of DynaBean, which gives the characteristics of Lazy List and Lazy Map this connects the properties of DynaClass. There are four types of Lazy DynaBeans:Java BeanUtils - Background (Data Type Conversions)
Description
Data type conversion is a process of changing value from one data type to another. In the previous chapters, dynamically accessed properties of data types are recognized and to achieve the type conversions, we can use Java casts. The BeanUtils package gives various types of APIs and design patterns for performing the data type conversions.Java BeanUtils - BeanUtils and ConvertUtils
Description
The BeanUtils is defined as a utility method for populating JavaBeans properties and ConvertUtils method converts string scalar values to objects, string arrays to arrays of the specified class.Java BeanUtils - Create Custom Converters
Description
BeanUtils package allows creating your own string object to convert for any java class and the registered converters can be used by all the BeanUtils methods.The following are the steps to create and register your own converter:
Java BeanUtils - Locale Aware Conversions
Description
The regular classes available in org.apache.commons.beanutils are not assigned for any specific event. These classes provide a clear interface to make use of situations very easily where the locale is not main thing. You can use Locale-aware extensions of beanutils classes which helps localization, from the org.apache.commons.beanutils.locale package.Java BeanUtils - Utility Objects & Classes
Description
The utility classes such as BeanUtils, ConvertUtils and PropertyUtils can be accessed through utility objects and shares the same caches and registered converters. You can instantiate corresponding class with same functionality for each static utility class.Java BeanUtils - Comparing Beans
Description
In Apache Commons Beanutils, you can compare the JavaBean objects by using the BeanComparator class based on a specified shared property value. This can be done by using the org.apache.commons.beanutils.BeanComparator comparator.Java BeanUtils - Operating On Collections
Description
The Commons-Collections are build upon interfaces, implementations and utilities. It contains Closure interface in the code that can be applied on the arbitrary input object and code permits to apply Closures to contents of collection.Java BeanUtils - Querying Or Filtering Collections
Description
The collections of beans can be filtered in the commons-collections by using the interface Predicate and also provides either true or false value on the evaluation of an input object. There is a Predicate called BeanPropertyValueEqualsPredicate which will assess the set property value against the given value.Java BeanUtils - Transforming Collections
Description
The conversion from input object to output object is supported in commons-collections with the help of Transformer interface. The Transformers can be applied to get the output collection from input collection with the help of codes available in Commons-collections.Java 8 - Overview
JAVA 8 (aka jdk 1.8) is a major release of JAVA programming language development. Its initial version was released on 18 March 2014. With the Java 8 release, Java provided support for functional programming, new JavaScript engine, new APIs for date time manipulation, new streaming API, etc.
Java 8 - Environment Setup
Try it Option Online
We have set up the Java Programming environment online, so that you can compile and execute all the available examples online. It gives you confidence in what you are reading and enables you to verify the programs with different options.
Java 8 - Lambda Expressions
Lambda expressions are introduced in Java 8 and are touted to be the
biggest feature of Java 8. Lambda expression facilitates functional
programming, and simplifies the development a lot.
Java 8 - Method References
Method references help to point to methods by their names. A method reference is described using
::
(double colon) symbol. A method reference can be used to point the following types of methods −Java 8 - Functional Interfaces
Functional interfaces have a single functionality to exhibit. For
example, a Comparable interface with a single method ‘compareTo’ is used
for comparison purpose. Java 8 has defined a lot of functional
interfaces to be used extensively in lambda expressions. Following is
the list of functional interfaces defined in java.util.Function package.
Java 8 - Default Methods
Java 8 introduces a new concept of default method implementation in
interfaces. This capability is added for backward compatibility so that
old interfaces can be used to leverage the lambda expression capability
of Java 8.
Java 8 - Streams
Stream is a new abstract layer introduced in Java 8. Using stream,
you can process data in a declarative way similar to SQL statements. For
example, consider the following SQL statement −
SELECT max(salary), employee_id, employee_name FROM Employee
Java 8 - Optional Class
Optional is a container object which is used to contain not-null
objects. Optional object is used to represent null with absent value.
This class has various utility methods to facilitate code to handle
values as ‘available’ or ‘not available’ instead of checking null
values. It is introduced in Java 8 and is similar to what Optional is in Guava.
Note − This class inherits methods from the java.lang.Object class.
Class Declaration
Following is the declaration for java.util.Optional<T> class −public final class Optional<T> extends Object
Class Method
S. No. | Method & Description |
---|---|
1 | static <T> Optional<T> empty() Returns an empty Optional instance. |
2 | boolean equals(Object obj) Indicates whether some other object is "equal to" this Optional. |
3 | Optional<T> filter(Predicate<? super <T> predicate) If a value is present and the value matches a given predicate, it returns an Optional describing the value, otherwise returns an empty Optional. |
4 | <U> Optional<U> flatMap(Function<? super T,Optional<U>> mapper) If a value is present, it applies the provided Optional-bearing mapping function to it, returns that result, otherwise returns an empty Optional. |
5 | T get() If a value is present in this Optional, returns the value, otherwise throws NoSuchElementException. |
6 | int hashCode() Returns the hash code value of the present value, if any, or 0 (zero) if no value is present. |
7 | void ifPresent(Consumer<? super T> consumer) If a value is present, it invokes the specified consumer with the value, otherwise does nothing. |
8 | boolean isPresent() Returns true if there is a value present, otherwise false. |
9 | <U>Optional<U> map(Function<? super T,? extends U> mapper) If a value is present, applies the provided mapping function to it, and if the result is non-null, returns an Optional describing the result. |
10 | static <T> Optional<T> of(T value) Returns an Optional with the specified present non-null value. |
11 | static <T> Optional<T> ofNullable(T value) Returns an Optional describing the specified value, if non-null, otherwise returns an empty Optional. |
12 | T orElse(T other) Returns the value if present, otherwise returns other. |
13 | T orElseGet(Supplier<? extends T> other) Returns the value if present, otherwise invokes other and returns the result of that invocation. |
14 | <X extends Throwable> T orElseThrow(Supplier<? extends X> exceptionSupplier) Returns the contained value, if present, otherwise throws an exception to be created by the provided supplier. |
15 | String toString() Returns a non-empty string representation of this Optional suitable for debugging. |
Optional Example
To understand how Optional is used in practice, let us see the following example. Write the following program, execute and verify result to get more insight of it.Java8Tester.java
import java.util.Optional; public class Java8Tester { public static void main(String args[]){ Java8Tester java8Tester = new Java8Tester(); Integer value1 = null; Integer value2 = new Integer(10); //Optional.ofNullable - allows passed parameter to be null. Optional<Integer> a = Optional.ofNullable(value1); //Optional.of - throws NullPointerException if passed parameter is null Optional<Integer> b = Optional.of(value2); System.out.println(java8Tester.sum(a,b)); } public Integer sum(Optional<Integer> a, Optional<Integer> b){ //Optional.isPresent - checks the value is present or not System.out.println("First parameter is present: " + a.isPresent()); System.out.println("Second parameter is present: " + b.isPresent()); //Optional.orElse - returns the value if present otherwise returns //the default value passed. Integer value1 = a.orElse(new Integer(0)); //Optional.get - gets the value, value should be present Integer value2 = b.get(); return value1 + value2; } }
Verify the Result
Compile the class using javac compiler as follows −$javac Java8Tester.javaNow run the Java8Tester as follows −
$java Java8TesterIt should produce the following output −
First parameter is present: false Second parameter is present: true 10
Java 8 - Nashorn JavaScript
With Java 8, Nashorn, a much improved javascript engine is
introduced, to replace the existing Rhino. Nashorn provides 2 to 10
times better performance, as it directly compiles the code in memory and
passes the bytecode to JVM. Nashorn uses invokedynamics feature, introduced in Java 7 to improve performance.
Java 8 - New Date/Time API
With Java 8, a new Date-Time API is introduced to cover the following drawbacks of old date-time API −
- Not thread safe − java.util.Date is not thread safe, thus developers have to deal with concurrency issue while using date. The new date-time API is immutable and does not have setter methods.
Java 8 - Base64
With Java 8, Base64 has finally got its due. Java 8 now has inbuilt encoder and decoder for Base64 encoding. In Java 8, we can use three types of Base64 encoding −
Java 8 Questions and Answers
Java 8 Questions and Answers has been designed with a special intention of helping students and professionals preparing for various Certification Exams and Job Interviews. This section provides a useful collection of sample Interview Questions and Multiple Choice Questions (MCQs) and their answers with appropriate explanations.
Java 8 - Quick Guide
Java 8 - Overview
JAVA 8 is a major feature release of JAVA programming language development. Its initial version was released on 18 March 2014. With the Java 8 release, Java provided supports for functional programming, new JavaScript engine, new APIs for date time manipulation, new streaming API, etc.Java 8 - Useful Resources
The following resources contain additional information on Java8. Please use them to get more in-depth knowledge on this tpoic.
Discuss Java 8
Java 8 is the most awaited and is a major feature release of Java
programming language. This is an introductory tutorial that explains the
basic-to-advanced features of Java 8 and their usage in a simple and
intuitive way.
Thursday, February 2, 2017
Groovy - Overview
Groovy is an object oriented language which is based on Java
platform. Groovy 1.0 was released in January 2, 2007 with Groovy 2.4 as
the current major release. Groovy is distributed via the Apache License v
2.0.
Groovy - Environment
There are a variety of ways to get the Groovy environment setup.
Binary download and installation − Go to the link www.groovy-lang.org/download.html to get the Windows Installer section. Click on this option to start the download of the Groovy installer.
Binary download and installation − Go to the link www.groovy-lang.org/download.html to get the Windows Installer section. Click on this option to start the download of the Groovy installer.
Groovy - Basic Syntax
In order to understand the basic syntax of Groovy, let’s first look at a simple Hello World program.
Creating Your First Hello World Program
Creating your first hello world program is as simple as just entering the following code line −class Example { static void main(String[] args) { // Using a simple println statement to print output to the console println('Hello World');
Groovy - Data Types
In any programming language, you need to use various variables to
store various types of information. Variables are nothing but reserved
memory locations to store values. This means that when you create a
variable you reserve some space in memory to store the value associated
with the variable.
Groovy - Variables
Variables in Groovy can be defined in two ways − using the native syntax for the data type or the next is by using the def keyword.
For variable definitions it is mandatory to either provide a type name
explicitly or to use "def" in replacement. This is required by the
Groovy parser.
Groovy - Operators
An operator is a symbol that tells the compiler to perform specific mathematical or logical manipulations.
Groovy has the following types of operators −
Groovy has the following types of operators −
- Arithmetic operators
- Relational operators
- Logical operators
- Bitwise operators
- Assignment operators
Groovy - Loops
So far, we have seen statements which have been executed one after
the other in a sequential manner. Additionally, statements are provided
in Groovy to alter the flow of control in a program’s logic. They are
then classified into flow of control statements which we will see in
detail.
Groovy - Decision Making
Decision-making structures require that the programmer specify one or
more conditions to be evaluated or tested by the program, along with a
statement or statements to be executed if the condition is determined to
be true, and optionally, other statements to be executed if the condition is determined to be false.
Groovy - Methods
A method is in Groovy is defined with a return type or with the def
keyword. Methods can receive any number of arguments. It’s not
necessary that the types are explicitly defined when defining the
arguments. Modifiers such as public, private and protected can be added.
By default, if no visibility modifier is provided, the method is
public.
Groovy - File I/O
Groovy provides a number of helper methods when working with I/O.
Groovy provides easier classes to provide the following functionalities
for files.
- Reading files
- Writing to files
- Traversing file trees
- Reading and writing data objects to files
Groovy - Optionals
Groovy is an “optionally” typed language, and that distinction is an
important one when understanding the fundamentals of the language. When
compared to Java, which is a “strongly” typed language, whereby the
compiler knows all of the types for every variable and can understand
and honor contracts at compile time. This means that method calls are
able to be determined at compile time.
Groovy - Numbers
In Groovy, Numbers are actually represented as object’s, all of them
being an instance of the class Integer. To make an object do something,
we need to invoke one of the methods declared in its class.
Groovy supports integer and floating point numbers.
Groovy supports integer and floating point numbers.
Groovy - Strings
A String literal is constructed in Groovy by enclosing the string text in quotations.
Groovy offers a variety of ways to denote a String literal. Strings in Groovy can be enclosed in single quotes (’), double quotes (“), or triple quotes (“””). Further, a Groovy String enclosed by triple quotes may span multiple lines.
Groovy offers a variety of ways to denote a String literal. Strings in Groovy can be enclosed in single quotes (’), double quotes (“), or triple quotes (“””). Further, a Groovy String enclosed by triple quotes may span multiple lines.
Groovy - Ranges
A range is shorthand for specifying a sequence of values. A Range is
denoted by the first and last values in the sequence, and Range can be
inclusive or exclusive. An inclusive Range includes all the values from
the first to the last, while an exclusive Range includes all values
except the last. Here are some examples of Range literals −
Groovy - Lists
The List is a structure used to store a collection of data items. In
Groovy, the List holds a sequence of object references. Object
references in a List occupy a position in the sequence and are
distinguished by an integer index. A List literal is presented as a
series of objects separated by commas and enclosed in square brackets.
Groovy - Maps
A Map (also known as an associative array, dictionary, table, and
hash) is an unordered collection of object references. The elements in a
Map collection are accessed by a key value. The keys used in a Map can
be of any class. When we insert into a Map collection, two values are
required: the key and the value.
Following are some examples of maps −
Following are some examples of maps −
Groovy - Dates & Times
The class Date represents a specific instant in time, with
millisecond precision. The Date class has two constructors as shown
below.
Groovy - Regular Expressions
A regular expression is a pattern that is used to find substrings in
text. Groovy supports regular expressions natively using the ~”regex”
expression. The text enclosed within the quotations represent the
expression for comparison.
Groovy - Exception Handling
Exception handling is required in any programming language to handle
the runtime errors so that normal flow of the application can be
maintained.
Exception normally disrupts the normal flow of the application, which is the reason why we need to use Exception handling in our application.
Exceptions are broadly classified into the following categories −
Exception normally disrupts the normal flow of the application, which is the reason why we need to use Exception handling in our application.
Exceptions are broadly classified into the following categories −
Groovy - Object Oriented
In Groovy, as in any other Object-Oriented language, there is the
concept of classes and objects to represent the objected oriented nature
of the programming language. A Groovy class is a collection of data and
the methods that operate on that data. Together, the data and methods
of a class are used to represent some real world object from the problem
domain.
Groovy - Generics
Generics enable types (classes and interfaces) to be parameters when
defining classes, interfaces and methods. Much like the more familiar
formal parameters used in method declarations, type parameters provide a
way for you to re-use the same code with different inputs. The
difference is that the inputs to formal parameters are values, while the
inputs to type parameters are types.
Groovy - Traits
Traits are a structural construct of the language which allow −
- Composition of behaviors.
- Runtime implementation of interfaces.
- Compatibility with static type checking/compilation
Groovy - Closures
A closure is a short anonymous block of code. It just normally spans a
few lines of code. A method can even take the block of code as a
parameter. They are anonymous in nature.
Following is an example of a simple closure and what it looks like.
Following is an example of a simple closure and what it looks like.
Groovy - Annotations
Annotations are a form of metadata wherein they provide data
about a program that is not part of the program itself. Annotations have
no direct effect on the operation of the code they annotate.
Annotations are mainly used for the following reasons −
Annotations are mainly used for the following reasons −
Groovy - XML
XML is a portable, open source language that allows programmers to
develop applications that can be read by other applications, regardless
of operating system and/or developmental language. This is one of the
most common languages used for exchanging data between applications.
Groovy - JMX
JMX is the defacto standard which is used for monitoring all
applications which have anything to do with the Java virual environment.
Given that Groovy sits directly on top of Java, Groovy can leverage the
tremendous amount of work already done for JMX with Java.
Groovy - JSON
This chapter covers how to we can use the Groovy language for parsing and producing JSON objects.
JSON Functions
Function | Libraries |
---|---|
JsonSlurper | JsonSlurper is a class that parses JSON text or reader content into Groovy data Structures such as maps, lists and primitive types like Integer, Double, Boolean and String. |
JsonOutput | This method is responsible for serialising Groovy objects into JSON strings. |
Groovy - DSLS
Groovy allows one to omit parentheses around the arguments of a
method call for top-level statements. This is known as the "command
chain" feature. This extension works by allowing one to chain such
parentheses-free method calls, requiring neither parentheses around
arguments, nor dots between the chained calls.
Groovy - Database
Groovy’s groovy-sql module provides a higher-level abstraction over
the current Java’s JDBC technology. The Groovy sql API supports a wide
variety of databases, some of which are shown below.
- HSQLDB
- Oracle
- SQL Server
- MySQL
- MongoDB
Groovy - Builders
During the process of software development, sometimes developers
spend a lot of time in creating Data structures, domain classes, XML,
GUI Layouts, Output streams etc.And sometimes the code used to create
these specific requirements results in the repitition of the same
snippet of code in many places.
Groovy - Command Line
The Groovy shell known as groovysh can be easily used to evaluate
groovy expressions, define classes and run simple programs. The command
line shell gets installed when Groovy is installed.
Following are the command line options available in Groovy −
Following are the command line options available in Groovy −
Groovy - Unit Testing
The fundamental unit of an object-oriented system is the class.
Therefore unit testing consists of testig within a class. The approach
taken is to create an object of the class under testing and use it to
check that selected methods execute as expected. Not every method can be
tested, since it is not always pratical to test each and every thing.
But unit testing should be conducted for key and critical methods.
Groovy - Template Engines
Groovy’s template engine operates like a mail merge (the automatic
addition of names and addresses from a database to letters and envelopes
in order to facilitate sending mail, especially advertising, to many
addresses) but it is much more general.
Groovy - Meta Object Programming
Meta object programming or MOP can be used to invoke methods dynamically and also create classes and methods on the fly.
So what does this mean? Let’s consider a class called Student, which is kind of an empty class with no member variables or methods.
So what does this mean? Let’s consider a class called Student, which is kind of an empty class with no member variables or methods.
Groovy - Quick Guide
Groovy - Overview
Groovy is an object oriented language which is based on Java platform. Groovy 1.0 was released in January 2, 2007 with Groovy 2.4 as the current major release. Groovy is distributed via the Apache License v 2.0.Groovy - Useful Resources
The following resources contain additional information on Groovy. Please use them to get more in-depth knowledge on this.
Discuss Groovy
Groovy is an object oriented language which is based on Java platform.
Groovy 1.0 was released in January 2, 2007 with Groovy 2.4 as the
current major release. Groovy is distributed via the Apache License v
2.0. In this tutorial, we would explain all the fundamentals of Groovy
and how to put it into practice.
Go - Overview
Go is a general-purpose language designed with systems programming in
mind.It was initially developed at Google in year 2007 by Robert
Griesemer, Rob Pike, and Ken Thompson. It is strongly and statically
typed, provides inbuilt support for garbage collection and supports
concurrent programming.
Go - Environment Setup
Try it Option Online
You really do not need to set up your own environment to start learning Go programming language. Reason is very simple, we already have set up Go Programming environment online, so that you can compile and execute all the available examples online at the same time when you are doing your theory work.
Go - Program Structure
Before we study basic building blocks of the Go programming language,
let us look a bare minimum Go program structure so that we can take it
as a reference in upcoming chapters.
Go - Basic Syntax
You have seen a basic structure of Go program, so it will be easy to
understand other basic building blocks of the Go programming language.
Go - Data Types
In the Go programming language, data types refer to an extensive
system used for declaring variables or functions of different types. The
type of a variable determines how much space it occupies in storage and
how the bit pattern stored is interpreted.
Go - Variables
A variable is nothing but a name given to a storage area that our
programs can manipulate. Each variable in Go has a specific type, which
determines the size and layout of the variable's memory; the range of
values that can be stored within that memory; and the set of operations
that can be applied to the variable.
Go - Constants
The constants refer to fixed values that the program may not alter during its execution. These fixed values are also called literals.
Constants can be of any of the basic data types like an integer constant, a floating constant, a character constant, or a string literal. There are also enumeration constants as well.
The constants are treated just like regular variables except that their values cannot be modified after their definition.
Constants can be of any of the basic data types like an integer constant, a floating constant, a character constant, or a string literal. There are also enumeration constants as well.
The constants are treated just like regular variables except that their values cannot be modified after their definition.
Go - Operators
An operator is a symbol that tells the compiler to perform specific
mathematical or logical manipulations. Go language is rich in built-in
operators and provides the following types of operators:
- Arithmetic Operators
- Relational Operators
- Logical Operators
- Bitwise Operators
- Assignment Operators
- Misc Operators
Go - Decision Making
Decision making structures require that the programmer specify one or
more conditions to be evaluated or tested by the program, along with a
statement or statements to be executed if the condition is determined to
be true, and optionally, other statements to be executed if the
condition is determined to be false.
Go - Loops
There may be a situation, when you need to execute a block of code
several number of times. In general, statements are executed
sequentially: The first statement in a function is executed first,
followed by the second, and so on.
Go - Functions
A function is a group of statements that together perform a task. Every Go program has at least one function, which is main(), and all the most trivial programs can define additional functions.
Go - Scope Rules
A scope in any programming is a region of the program where a defined
variable can have its existence and beyond that variable can not be
accessed. There are three places where variables can be declared in C
programming language:
Go - Arrays
Go programming language provides a data structure called the array,
which can store a fixed-size sequential collection of elements of the
same type. An array is used to store a collection of data, but it is
often more useful to think of an array as a collection of variables of
the same type.
Go - Pointers
Pointers in Go are easy and fun to learn. Some Go programming tasks
are performed more easily with pointers, and other tasks, such as call
by reference, cannot be performed without using pointers. So it becomes
necessary to learn pointers to become a perfect Go programmer. Let's
start learning them in simple and easy steps.
Go - Structures
Go arrays allow you to define type of variables that can hold several data items of the same kind but structure is another user defined data type available in Go programming, which allows you to combine data items of different kinds.
Go - Slices
Go Slice is an abstraction over Go Array. As Go Array allows you to
define type of variables that can hold several data items of the same
kind but it do not provide any inbuilt method to increase size of it
dynamically or get a sub-array of its own. Slices covers this
limitation. It provides many utility functions required on Array and is
widely used in Go programming.
Go - Range
The range keyword is used in for loop to iterate over
items of an array, slice, channel or map. With array and slices, it
returns the index of the item as integer. With maps, it returns the key
of the next key-value pair. Range either returns one value or two. If
only one value is used on the left of a range expression, it is the 1st
value in the following table.
Go - Maps
Go provides another important data type map which maps unique keys to
values. A key is an object that you use to retrieve a value at a later
date. Given a key and a value, you can strore the value in a Map object.
After value is stored, you can retrieve it by using its key.
Go - Recursion
Recursion is the process of repeating items in a self-similar way.
Same applies in programming languages as well where if a programming
allows you to call a function inside the same function that is called
recursive call of the function as follows.
Go - Type Casting
Type casting is a way to convert a variable from one data type to
another data type. For example, if you want to store a long value into a
simple integer then you can type cast long to int. You can convert
values from one type to another using the cast operator as following:
Go - Interfaces
Go programming provides another data type called interfaces which represents a set of method signatures. struct data type implements these interfaces to have metho definitions for the method signature of the interfaces.
Go - Error Handling
Go programming provides a pretty simple error handling framework with inbuit error interface type of following declaration:
type error interface { Error() string }
Go Questions and Answers
Go Questions and Answers has been designed with a special intention of helping students and professionals preparing for various Certification Exams and Job Interviews. This section provides a useful collection of sample Interview Questions and Multiple Choice Questions (MCQs) and their answers with appropriate explanations.
Go - Quick Guide
Go - Overview
Go is a general-purpose language designed with systems programming in mind.It was initially developed at Google in year 2007 by Robert Griesemer, Rob Pike, and Ken Thompson. It is strongly and statically typed, provides inbuilt support for garbage collection and supports concurrent programming. Programs are constructed using packages, for efficient management of dependencies. Go programming implementations use a traditional compile and link model to generate executable binaries.Go - Useful Resources
If you want to list down your website, book or any other resource on
this page then please contact at webmaster@tutorialspoint.com
Discuss Go
Go language, is a programming language initially developed at Google in year 2007 by Robert Griesemer, Rob Pike, and Ken Thompson. Go programming language is a statically-typed language with syntax similar to that of C. It provides garbage collection, type safety, dynamic-typing capability, many advanced built-in types such as variable length arrays and key-value maps. It also provides a rich standard library. The Go programming language was announced in November 2009 and is used in some of the Google's production systems.
Wednesday, February 1, 2017
F# - Overview
F# is a functional programming language. To understand F# constructs,
you need to read a couple of lines about the programming paradigm named
Functional Programming.
Functional programming treats computer programs as mathematical functions.
Functional programming treats computer programs as mathematical functions.
F# - Environment Setup
The tools required for F# programming are discussed in this chapter.
The free Visual Studio 2013 Community Edition is available from Microsoft’s official website. Visual Studio 2013 Community and above comes with the Visual F# Tools.
Integrated Development Environment(IDE) for F#
Microsoft provides Visual Studio 2013 for F# programming.The free Visual Studio 2013 Community Edition is available from Microsoft’s official website. Visual Studio 2013 Community and above comes with the Visual F# Tools.
F# - Program Structure
F# is a Functional Programming language.
In F#, functions work like data types. You can declare and use a function in the same way like any other variable.
In general, an F# application does not have any specific entry point. The compiler executes all top-level statements in the file from top to bottom.
In F#, functions work like data types. You can declare and use a function in the same way like any other variable.
In general, an F# application does not have any specific entry point. The compiler executes all top-level statements in the file from top to bottom.
F# - Basic Syntax
You have seen the basic structure of an F# program, so it will be
easy to understand other basic building blocks of the F# programming
language.
F# - Data Types
The data types in F# can be classified as follows −
- Integral types
- Floating point types
- Text types
- Other types
F# - Variables
A variable is a name given to a storage area that our programs can
manipulate. Each variable has a specific type, which determines the size
and layout of the variable's memory; the range of values that can be
stored within that memory; and the set of operations that can be applied
to the variable.
F# - Operators
An operator is a symbol that tells the compiler to perform specific
mathematical or logical manipulations. F# is rich in built-in operators
and provides the following types of operators −
- Arithmetic Operators
- Comparison Operators
- Boolean Operators
- Bitwise Operators
F# - Decision Making
Decision making structures require that the programmer specify one or
more conditions to be evaluated or tested by the program. It should be
along with a statement or statements to be executed if the condition is
determined to be true, and optionally, other statements to be executed
if the condition is determined to be false.
F# - Loops
Programming languages provide various control structures that allow for more complicated execution paths.
A loop statement allows us to execute a statement or group of statements multiple times and following is the general form of a loop statement in most of the programming languages −
A loop statement allows us to execute a statement or group of statements multiple times and following is the general form of a loop statement in most of the programming languages −
F# - Functions
In F#, functions work like data types. You can declare and use a function in the same way like any other variable.
Since functions can be used like any other variables, you can −
Since functions can be used like any other variables, you can −
F# - Strings
In F#, the string type represents immutable text as a sequence of Unicode characters.
Some special characters are there for special uses like newline, tab, etc. They are encoded using backslash (\) character. The backslash character and the related character make the escape sequence. The following table shows the escape sequence supported by F#.
String Literals
String literals are delimited by the quotation mark (") character.Some special characters are there for special uses like newline, tab, etc. They are encoded using backslash (\) character. The backslash character and the related character make the escape sequence. The following table shows the escape sequence supported by F#.
F# - Options
The option type in F# is used in calculations when there may
or may not exist a value for a variable or function. Option types are
used for representing optional values in calculations. They can have two
possible values − Some(x) or None.
F# - Tuples
A tuple is a comma-separated collection of values. These are
used for creating ad hoc data structures, which group together related
values.
For example, (“Zara Ali”, “Hyderabad”, 10) is a 3-tuple with two string values and an int value, it has the type (string * string * int).
For example, (“Zara Ali”, “Hyderabad”, 10) is a 3-tuple with two string values and an int value, it has the type (string * string * int).
F# - Records
A record is similar to a tuple, however it contains named fields. For example,
type website = { title : string; url : string }
Defining Record
F# - Lists
In F#, a list is an ordered, immutable series of elements of the same
type. It is to some extent equivalent to a linked list data structure.
The F# module, Microsoft.FSharp.Collections.List, has the common operations on lists. However F# imports this module automatically and makes it accessible to every F# application.
The F# module, Microsoft.FSharp.Collections.List, has the common operations on lists. However F# imports this module automatically and makes it accessible to every F# application.
F# - Sequences
Sequences, like lists also represent an ordered collection of values.
However, the elements in a sequence or sequence expression are computed
when required. They are not computed at once, and for this reason they
are used to represent infinite data structures.
F# - Sets
A set in F# is a data structure that acts as a collection of items
without preserving the order in which items are inserted. Sets do not
allow duplicate entries to be inserted into the collection.
F# - Maps
In F#, a map is a special kind of set that associates the values with
key. A map is created in a similar way as sets are created.
Creating Maps
Maps are created by creating an empty map using Map.empty and adding items using the Add function. The following example demonstrates this −F# - Discriminated Unions
Unions, or discriminated unions allows you to build up complex data
structures representing well-defined set of choices. For example, you
need to build an implementation of a choice variable, which has two values yes and no. Using the Unions tool, you can design this.
F# - Mutable Data
Variables in F# are immutable, which means once a variable is
bound to a value, it can’t be changed. They are actually compiled as
static read-only properties.
The following example demonstrates this.
The following example demonstrates this.
F# - Arrays
Arrays are fixed-size, zero-based, mutable collections of consecutive data elements that are all of the same type.
There are three syntactical ways of creating arrays without functions −
Creating Arrays
You can create arrays using various syntaxes and ways or by using the functions from the Array module. In this section, we will discuss creating arrays without using the module functions.There are three syntactical ways of creating arrays without functions −
F# - Mutable Lists
The List<'T> class represents a strongly typed list of objects that can be accessed by index.
It is a mutable counterpart of the List class. It is similar to arrays, as it can be accessed by an index, however, unlike arrays, lists can be resized. Therefore you need not specify a size during declaration.
It is a mutable counterpart of the List class. It is similar to arrays, as it can be accessed by an index, however, unlike arrays, lists can be resized. Therefore you need not specify a size during declaration.
F# - Mutable Dictionary
The Dictionary<'TKey, 'TValue> class is the mutable analog of the F# map data structure and contains many of the same functions.
Recapitulating from the Map chapter in F#, a map is a special kind of set that associates the values with key.
Recapitulating from the Map chapter in F#, a map is a special kind of set that associates the values with key.
F# - Basic I/O
Basic Input Output includes −
- Reading from and writing into console.
- Reading from and writing into file.
Core.Printf Module
We have used the printf and the printfn functions for writing into the console. In this section, we will look into the details of the Printf module of F#.F# - Generics
Generics allow you to delay the specification of the data type of
programming elements in a class or a method, until it is actually used
in the program. In other words, generics allow you to write a class or
method that can work with any data type.
F# - Delegates
A delegate is a reference type variable that holds the reference to a
method. The reference can be changed at runtime. F# delegates are
similar to pointers to functions, in C or C++.
F# - Enumerations
An enumeration is a set of named integer constants.
In F#, enumerations, also known as enums, are integral types where labels are assigned to a subset of the values. You can use them in place of literals to make code more readable and maintainable.
In F#, enumerations, also known as enums, are integral types where labels are assigned to a subset of the values. You can use them in place of literals to make code more readable and maintainable.
F# - Pattern Matching
Pattern matching allows you to “compare data with a logical structure
or structures, decompose data into constituent parts, or extract
information from data in various ways”.
In other terms, it provides a more flexible and powerful way of testing data against a series of conditions and performing some computations based on the condition met.
Conceptually, it is like a series of if… then statements.
In other terms, it provides a more flexible and powerful way of testing data against a series of conditions and performing some computations based on the condition met.
Conceptually, it is like a series of if… then statements.
F# - Exception Handling
An exception is a problem that arises during the execution of a
program. An F# exception is a response to an exceptional circumstance
that arises while a program is running, such as an attempt to divide by
zero.
Exceptions provide a way to transfer control from one part of a program to another. F# exception handling provides the following constructs −
Exceptions provide a way to transfer control from one part of a program to another. F# exception handling provides the following constructs −
Subscribe to:
Posts (Atom)