Please enable JavaScript.
Coggle requires JavaScript to display documents.
Functional Programming - Coggle Diagram
Functional Programming
It is a declarative type of programming style. Its main focus is on “what to solve” in contrast to an imperative style where the main focus is “how to solve”. It uses expressions instead of statements.
Pure functions: These functions have two main properties. First, they always produce the same output for same arguments irrespective of anything else.
Secondly, they have no side-effects i.e. they do not modify any arguments or local/global variables or input/output streams. :
-
There are no “for” or “while” loop in functional languages. Iteration in functional languages is implemented through recursion. Recursive functions repeatedly call themselves, until it reaches the base case.
example of the recursive function
Functional Programming variables are immutable, meaning pure function’s only result is the value it returns. The variable can not be able changed useless it is stated to me mutable.
First-class functions are treated as first-class variable. The first class variables can be passed to functions as parameter, can be returned from functions or stored in data structures. Higher order functions are the functions that take other functions as arguments and they can also return functions.
Functional programming is a programming paradigm in which we try to bind everything in pure mathematical functions style.
functional programming are easy to debug because pure functions have no side effects or hidden I/O. Pure functions also make it easier to write parallel/concurrent applications. :
-
-
Parser
is a compiler or interpreter component that breaks data into smaller elements for easy translation into another language. A parser takes input in the form of a sequence of tokens, interactive commands, or program instructions and breaks them up into parts that can be used by other components in programming.
Semantic Parsing: The final parsing stage in which the meaning and implications of the validated expression are determined and necessary actions are taken.
A lexical analyzer is used to produce tokens from a stream of input string characters, which are broken into small components to form meaningful expressions.
Syntactic Analysis: Checks whether the generated tokens form a meaningful expression. This makes use of a context-free grammar that defines algorithmic procedures for components
A token is the smallest unit in a programming language that possesses some meaning (such as +, -, *, “function”, or “new” in JavaScript).
Top-Down Parsing: Involves searching a parse tree to find the left-most derivations of an input stream by using a top-down expansion. Parsing begins with the start symbol which is transformed into the input symbol until all symbols are translated and a parse tree for an input string is constructed.
Bottom-Up Parsing: Involves rewriting the input back to the start symbol. It acts in reverse by tracing out the rightmost derivation of a string until the parse tree is constructed up to the start symbol This type of parsing is also known as shift-reduce parsing.
CS 351
To convert source code into machine code, we use either a compiler or an interpreter.
Compiler
-
Compilers usually take a large amount of time to analyze the source code. However, the overall execution time is comparatively faster than interpreters
Generates Object Code which further requires linking, hence requires more memory.
Programming languages like C, C++, Java use compilers.
Interpreter
-
Interpreters usually take less amount of time to analyze the source code. However, the overall execution time is comparatively slower than compilers.
No Object Code is generated, hence are memory efficient.
Programming languages like JavaScript, Python, Ruby use interpreters.
Parallel processing approach –
Parallel processing is the processing of program instructions by dividing them among multiple processors. A parallel processing system posses many numbers of processor with the objective of running a program in less time by dividing them. This approach seems to be like divide and conquer. Examples are NESL (one of the oldest one) and C/C++ also supports because of some library function.
Procedural programming paradigm –
This paradigm emphasizes on procedure in terms of under lying machine model. There is no difference in between procedural and imperative approach. It has the ability to reuse the code and it was boon at that time when it was in use because of its reusability.
Object oriented programming –
The program is written as a collection of classes and object which are meant for communication. The smallest and basic entity is object and all kind of computation is performed on the objects only. More emphasis is on data rather procedure. It can handle almost all kind of real life problems which are today in scenario
Declarative programming paradigm:
It is divided as Logic, Functional, Database. In computer science the declarative programming is a style of building programs that expresses logic of computation without talking about its control flow. It often considers programs as theories of some logic.It may simplify writing parallel programs. The focus is on what needs to be done rather how it should be done basically emphasize on what code code is actually doing.
Logic programming paradigms –
It can be termed as abstract model of computation. It would solve logical problems like puzzles, series etc. In logic programming we have a knowledge base which we know before and along with the question and knowledge base which is given to machine, it produces result.
Database/Data driven programming approach –
This programming methodology is based on data and its movement. Program statements are defined by data rather than hard-coding a series of steps. A database program is the heart of a business information system and provides file creation, data entry, update, query and reporting functions.
This course has large amount of discussion and hands-on-practice based components. It has a strong
emphasis on engaging everyone to actively participating in discussion, team collaboration, and hands-on
coding throughout the semester
Goal 1: How PL is made, compiler theory, principle of PL
(Build a basic compiler with Lexer and Parser)
Goal 2: 3 different PL paradigms
(Event driven with Python GUI, Functional with F#, Logic with Prolog)
Goal 3: How to learn PL more efficiently
(Hands-on active learning labs, using online technical materials, technical googling practices)
python syntax
-
Loop
fruits = ["apple", "banana", "cherry"]
for x in fruits:
print(x)
List
thislist = ["apple", "banana", "cherry"]
print(thislist)
Class
class Person:
def init(self, name, age):
self.name = name
self.name = age
-