SlideShare uma empresa Scribd logo
1 de 47
Programming Paradigms ( http://www.directi.com  |  http://wiki.directi.com  |  http://careers.directi.com )‏ Licensed under Creative Commons Attribution Sharealike Noncommercial By, Janeve George [email_address] & Nilesh Mevada [email_address]
Creative Commons Sharealike Attributions Noncommercial Few Instruction ,[object Object],[object Object],[object Object]
Creative Commons Sharealike Attributions Noncommercial Aim of the session ,[object Object],[object Object],Q: Why there are so many programming paradigms? A:  Q: Isn't there 'one language' that would suffice? A: Q: How can we deal with understanding so many paradigms? A:
Creative Commons Sharealike Attributions Noncommercial Flow of the session ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Creative Commons Sharealike Attributions Noncommercial Flow of the session ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Creative Commons Sharealike Attributions Noncommercial Programming Paradigm - Definition ,[object Object],[object Object],[object Object],Function Oriented Object Oriented Logical Programming Java ML Haskell Prolog Mercury Oz Erlang Smalltalk
Creative Commons Sharealike Attributions Noncommercial Flow of the session ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Creative Commons Sharealike Attributions Noncommercial Why bother about 'Programming Paradigms'?
Creative Commons Sharealike Attributions Noncommercial Why bother about 'Programming Paradigms'?
Creative Commons Sharealike Attributions Noncommercial Why bother about 'Programming Paradigms'?
Creative Commons Sharealike Attributions Noncommercial Why bother about 'Programming Paradigms'? ,[object Object],[object Object],[object Object],[object Object]
Creative Commons Sharealike Attributions Noncommercial Flow of the session ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Creative Commons Sharealike Attributions Noncommercial Appreciating 'Programming paradigms' ,[object Object],Int X; Int Y = X; Print( Y ); ,[object Object],?
Creative Commons Sharealike Attributions Noncommercial Flow of the session ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Creative Commons Sharealike Attributions Noncommercial Programming Concepts – An Overview Set of  Programming Concepts Procedures Functions Higher/1 st  Order Evaluation Eager/Lazy Variables Single/Multi store Scope Scope of variables Typing State Internal/External Objects Classes Concurrency & on & on & on.....
Creative Commons Sharealike Attributions Noncommercial Programming Concepts – An Overview Subset of Concepts Programming Model Set of Programming Concepts Programming Language(s)‏ Embraced by Followed by Embraced by Followed by
Creative Commons Sharealike Attributions Noncommercial Programming Concepts – An Overview Subset of Concepts OO Programming Model Set of Programming Concepts OO Programming Language(s)‏ Embraced by Followed by ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Embraced by Followed by
Creative Commons Sharealike Attributions Noncommercial Programming Concepts – An Overview Subset of Concepts Functional Programming Model Set of Programming Concepts Functional Programming Language(s)‏ Embraced by Followed by ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Embraced by Followed by
Creative Commons Sharealike Attributions Noncommercial Programming Concepts – An Overview
Creative Commons Sharealike Attributions Noncommercial Programming Concepts – An Overview
Creative Commons Sharealike Attributions Noncommercial ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Programming Concepts – An Overview
Creative Commons Sharealike Attributions Noncommercial Programming Concepts – Eager Evaluation ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Creative Commons Sharealike Attributions Noncommercial Programming Concepts – Eager Evaluation .... List  Gen (  int   N ) { ArrayList list =  new  ArrayList(); list. add ( N ); list. addAll (  Gen (N+1) ); return  list; } void   myMethod  () { List K =  Gen (1); System.out. println ( "Elements: " + K. getElementAt ( 3 ) ); } ....
Creative Commons Sharealike Attributions Noncommercial Programming Concepts – Lazy Evaluation ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Creative Commons Sharealike Attributions Noncommercial Programming Concepts – Lazy Evaluation declare fun lazy  { Gen  N}  N | { Gen  N+1} end declare  K = { Gen  1} { Browse  “Elements: ” + Nth K 3}
Creative Commons Sharealike Attributions Noncommercial Programming Concepts – Procedures ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],proc  { Max  X Y ?Z} if  X>=Y  then  Z=X  else  Z=Y  end end
Creative Commons Sharealike Attributions Noncommercial Programming Concepts – Procedures local  Default MaxOrDefault  in Default=10 proc  { MaxOrDefault  Arg ?Result} if  Arg >= Default  then   Result = Arg  else   Result = Default end end local   Result   in { MaxOrDefault  5 Result} { Browse  Result} end end
Creative Commons Sharealike Attributions Noncommercial Programming Concepts – Functions ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],fun  { Max  X Y} if  X>=Y  then  Z=X  else  Z=Y  end end Z = { Max  10, 20}
Creative Commons Sharealike Attributions Noncommercial Programming Concepts – Functions (Higher Order)‏ ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],map  f  []  =  [] map  f (x:xs) = f x :  map  f xs numbers =  [ 7,9,13 ] inc  x = x  +  1 more_numbers =  map   inc  numbers
Creative Commons Sharealike Attributions Noncommercial Programming Concepts – Functions (Higher Order)‏ listsum   []  = 0 listsum  (x:xs) = x  +   listsum  xs listprod   []   = 1 listprod  (x:xs) = x  *   listprod  xs fold  op init  []  = init fold  op init (x:xs) = x  `op`   fold op init xs listsum  =  fold  (+) 0 listprod  =  fold  (*) 1
Creative Commons Sharealike Attributions Noncommercial Programming Concepts – External and Internal State ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Creative Commons Sharealike Attributions Noncommercial Programming Concepts – External and Internal State fun  { Sum  Numbers} Result = { NewCell  0} Input = { NewCell  Numbers} proc  { Sum } case  @Input  of  nil  then skip [] X | Y  then Result := @Result + X Input := Y { Sum }  end end in { Sum } @Result end
Creative Commons Sharealike Attributions Noncommercial Programming Concepts – Concurrency ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],thread ConcurrentFlow1 = { GenerateNumbers  1 10} end
Creative Commons Sharealike Attributions Noncommercial Programming Concepts – Concurrency fun  { GenerateNumbers  FromArg ToArg} { Delay  100} if   FromArg > ToArg   then   nil else FromArg | { GenerateNumbers  FromArg+1 ToArg} end end thread   ConcurrentFlow1 = { GenerateNumbers  1 10} end thread ConcurrentFlow2 = { GenerateNumbers  11 20} end { Browse  ConcurrentFlow1} { Browse  ConcurrentFlow2}
Creative Commons Sharealike Attributions Noncommercial Programming Concepts – Concurrency .... public   void  main(String[] args)  throws   InterruptedException { Temp temp =  new   Temp(); createAConcurrentFlow(1, 10); createAConcurrentFlow(11, 20); } .... private   void  createAConcurrentFlow( int  FromArg,  int  ToArg) { new  Runnable() { public   void  run() { try   { new  Temp().GenerateNumbers(FromArg, ToArg); } catch  (InterruptedException e) {  } } }; } ....
Creative Commons Sharealike Attributions Noncommercial Programming Concepts – Static Typing ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Creative Commons Sharealike Attributions Noncommercial Programming Concepts – Static Typing int  num, sum;  // explicit declaration num = 5;  // now use the variables sum = 10; sum = sum + num;
Creative Commons Sharealike Attributions Noncommercial Programming Concepts – Dynamic Typing ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Creative Commons Sharealike Attributions Noncommercial Programming Concepts – Dynamic Typing foo() { x = 1; x = 'hello'; }
Creative Commons Sharealike Attributions Noncommercial Flow of the session ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Creative Commons Sharealike Attributions Noncommercial Some Real-Life Problems – Prolog vs Java % % Facts % male(hrithik). male(shahrukh). male(salman). male(abhishek). male(akshay). male(aamir). female(diya). female(aishwarya). female(katrina). female(malaika). parent(hrithik,shahrukh). parent(hrithik,salman). parent(hrithik,diya). parent(shahrukh,abhishek). parent(shahrukh,akshay). parent(salman,aishwarya). parent(salman,katrina). parent(salman,aamir). parent(diya,malaika). % % Rules % father(X,Y) :- parent(X,Y), male(X). mother(X,Y) :- parent(X,Y), female(X). grandparent(X,Y) :- parent(X,Z), parent(Z,Y). paternalgrandfather(X,Y) :- father(X,Z), father(Z,Y). sibling(X,Y) :- parent(Z,X), parent(Z,Y). brothers(X,Y) :- sibling(X,Y),male(X),male(Y),  (X=Y). % % Queries % cmd: mother(diya,malaika) % Outupt: yes/no cmd: mother(Mother,Child). % Output: lists (mother,child) pair found in facts  % according to associations defined
Creative Commons Sharealike Attributions Noncommercial Some Real-Life Problems – Statistics
Creative Commons Sharealike Attributions Noncommercial How to approach Programming Paradigm? ,[object Object],[object Object],[object Object],[object Object]
Creative Commons Sharealike Attributions Noncommercial References ,[object Object],[object Object],[object Object],[object Object],[object Object]
Creative Commons Sharealike Attributions Noncommercial What we expect post this session ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],“ I want to thank you and DIRECTI for conducting such a marvelous session and I am very much indebted for that.  I fell in love with LISP programming language and found that it was very much ideal for signal processing algos.  The approach u have suggested was just great and the book you have suggested was really really great.” - Chinni Krishna, Mukt '08 Session Attendee
Questions??? [email_address]  &  [email_address] http://directi.com http://careers.directi.com   Download slides:  http://wiki.directi.com
Retrospective!!! [email_address]  &  [email_address] http://directi.com http://careers.directi.com   Download slides:  http://wiki.directi.com

Mais conteúdo relacionado

Mais procurados

Mais procurados (18)

Presentation
PresentationPresentation
Presentation
 
Prgramming paradigms
Prgramming paradigmsPrgramming paradigms
Prgramming paradigms
 
Dart programming language
Dart programming languageDart programming language
Dart programming language
 
Architecting Domain-Specific Languages
Architecting Domain-Specific LanguagesArchitecting Domain-Specific Languages
Architecting Domain-Specific Languages
 
Dart ppt
Dart pptDart ppt
Dart ppt
 
Programming Paradigms
Programming ParadigmsProgramming Paradigms
Programming Paradigms
 
Programming Languages
Programming LanguagesProgramming Languages
Programming Languages
 
Programming paradigm
Programming paradigmProgramming paradigm
Programming paradigm
 
Dart the better Javascript 2015
Dart the better Javascript 2015Dart the better Javascript 2015
Dart the better Javascript 2015
 
Dart workshop
Dart workshopDart workshop
Dart workshop
 
Andy On Closures
Andy On ClosuresAndy On Closures
Andy On Closures
 
Agile development with Ruby
Agile development with RubyAgile development with Ruby
Agile development with Ruby
 
Programing paradigm & implementation
Programing paradigm & implementationPrograming paradigm & implementation
Programing paradigm & implementation
 
Dart presentation
Dart presentationDart presentation
Dart presentation
 
Concepts In Object Oriented Programming Languages
Concepts In Object Oriented Programming LanguagesConcepts In Object Oriented Programming Languages
Concepts In Object Oriented Programming Languages
 
Implementing Higher-Kinded Types in Dotty
Implementing Higher-Kinded Types in DottyImplementing Higher-Kinded Types in Dotty
Implementing Higher-Kinded Types in Dotty
 
Domain specific languages and Scala
Domain specific languages and ScalaDomain specific languages and Scala
Domain specific languages and Scala
 
Why functional programming in C# & F#
Why functional programming in C# & F#Why functional programming in C# & F#
Why functional programming in C# & F#
 

Semelhante a Programming Paradigms

Semelhante a Programming Paradigms (20)

PL Lecture 01 - preliminaries
PL Lecture 01 - preliminariesPL Lecture 01 - preliminaries
PL Lecture 01 - preliminaries
 
PARADIGM IT.pptx
PARADIGM IT.pptxPARADIGM IT.pptx
PARADIGM IT.pptx
 
Java
JavaJava
Java
 
Shuzworld Analysis
Shuzworld AnalysisShuzworld Analysis
Shuzworld Analysis
 
C++ book
C++ bookC++ book
C++ book
 
Designing function families and bundles with java's behaviors parameterisatio...
Designing function families and bundles with java's behaviors parameterisatio...Designing function families and bundles with java's behaviors parameterisatio...
Designing function families and bundles with java's behaviors parameterisatio...
 
Tools for the Toolmakers
Tools for the ToolmakersTools for the Toolmakers
Tools for the Toolmakers
 
Introduction to Software - Coder Forge - John Mulhall
Introduction to Software - Coder Forge - John MulhallIntroduction to Software - Coder Forge - John Mulhall
Introduction to Software - Coder Forge - John Mulhall
 
Programming for Problem Solving
Programming for Problem SolvingProgramming for Problem Solving
Programming for Problem Solving
 
Quick Intro to Clean Coding
Quick Intro to Clean CodingQuick Intro to Clean Coding
Quick Intro to Clean Coding
 
Javascript
JavascriptJavascript
Javascript
 
So You Just Inherited a $Legacy Application...
So You Just Inherited a $Legacy Application...So You Just Inherited a $Legacy Application...
So You Just Inherited a $Legacy Application...
 
Modern_2.pptx for java
Modern_2.pptx for java Modern_2.pptx for java
Modern_2.pptx for java
 
Framework engineering JCO 2011
Framework engineering JCO 2011Framework engineering JCO 2011
Framework engineering JCO 2011
 
So You Just Inherited a $Legacy Application… NomadPHP July 2016
So You Just Inherited a $Legacy Application… NomadPHP July 2016So You Just Inherited a $Legacy Application… NomadPHP July 2016
So You Just Inherited a $Legacy Application… NomadPHP July 2016
 
Core Java - OO Programming
Core Java - OO ProgrammingCore Java - OO Programming
Core Java - OO Programming
 
(Costless) Software Abstractions for Parallel Architectures
(Costless) Software Abstractions for Parallel Architectures(Costless) Software Abstractions for Parallel Architectures
(Costless) Software Abstractions for Parallel Architectures
 
Building and deploying LLM applications with Apache Airflow
Building and deploying LLM applications with Apache AirflowBuilding and deploying LLM applications with Apache Airflow
Building and deploying LLM applications with Apache Airflow
 
The Art of Evolutionary Algorithms Programming
The Art of Evolutionary Algorithms ProgrammingThe Art of Evolutionary Algorithms Programming
The Art of Evolutionary Algorithms Programming
 
Unit 1
Unit 1Unit 1
Unit 1
 

Último

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 

Último (20)

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 

Programming Paradigms

  • 1. Programming Paradigms ( http://www.directi.com | http://wiki.directi.com | http://careers.directi.com )‏ Licensed under Creative Commons Attribution Sharealike Noncommercial By, Janeve George [email_address] & Nilesh Mevada [email_address]
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8. Creative Commons Sharealike Attributions Noncommercial Why bother about 'Programming Paradigms'?
  • 9. Creative Commons Sharealike Attributions Noncommercial Why bother about 'Programming Paradigms'?
  • 10. Creative Commons Sharealike Attributions Noncommercial Why bother about 'Programming Paradigms'?
  • 11.
  • 12.
  • 13.
  • 14.
  • 15. Creative Commons Sharealike Attributions Noncommercial Programming Concepts – An Overview Set of Programming Concepts Procedures Functions Higher/1 st Order Evaluation Eager/Lazy Variables Single/Multi store Scope Scope of variables Typing State Internal/External Objects Classes Concurrency & on & on & on.....
  • 16. Creative Commons Sharealike Attributions Noncommercial Programming Concepts – An Overview Subset of Concepts Programming Model Set of Programming Concepts Programming Language(s)‏ Embraced by Followed by Embraced by Followed by
  • 17.
  • 18.
  • 19. Creative Commons Sharealike Attributions Noncommercial Programming Concepts – An Overview
  • 20. Creative Commons Sharealike Attributions Noncommercial Programming Concepts – An Overview
  • 21.
  • 22.
  • 23. Creative Commons Sharealike Attributions Noncommercial Programming Concepts – Eager Evaluation .... List Gen ( int N ) { ArrayList list = new ArrayList(); list. add ( N ); list. addAll ( Gen (N+1) ); return list; } void myMethod () { List K = Gen (1); System.out. println ( "Elements: " + K. getElementAt ( 3 ) ); } ....
  • 24.
  • 25. Creative Commons Sharealike Attributions Noncommercial Programming Concepts – Lazy Evaluation declare fun lazy { Gen N} N | { Gen N+1} end declare K = { Gen 1} { Browse “Elements: ” + Nth K 3}
  • 26.
  • 27. Creative Commons Sharealike Attributions Noncommercial Programming Concepts – Procedures local Default MaxOrDefault in Default=10 proc { MaxOrDefault Arg ?Result} if Arg >= Default then Result = Arg else Result = Default end end local Result in { MaxOrDefault 5 Result} { Browse Result} end end
  • 28.
  • 29.
  • 30. Creative Commons Sharealike Attributions Noncommercial Programming Concepts – Functions (Higher Order)‏ listsum [] = 0 listsum (x:xs) = x + listsum xs listprod [] = 1 listprod (x:xs) = x * listprod xs fold op init [] = init fold op init (x:xs) = x `op` fold op init xs listsum = fold (+) 0 listprod = fold (*) 1
  • 31.
  • 32. Creative Commons Sharealike Attributions Noncommercial Programming Concepts – External and Internal State fun { Sum Numbers} Result = { NewCell 0} Input = { NewCell Numbers} proc { Sum } case @Input of nil then skip [] X | Y then Result := @Result + X Input := Y { Sum } end end in { Sum } @Result end
  • 33.
  • 34. Creative Commons Sharealike Attributions Noncommercial Programming Concepts – Concurrency fun { GenerateNumbers FromArg ToArg} { Delay 100} if FromArg > ToArg then nil else FromArg | { GenerateNumbers FromArg+1 ToArg} end end thread ConcurrentFlow1 = { GenerateNumbers 1 10} end thread ConcurrentFlow2 = { GenerateNumbers 11 20} end { Browse ConcurrentFlow1} { Browse ConcurrentFlow2}
  • 35. Creative Commons Sharealike Attributions Noncommercial Programming Concepts – Concurrency .... public void main(String[] args) throws InterruptedException { Temp temp = new Temp(); createAConcurrentFlow(1, 10); createAConcurrentFlow(11, 20); } .... private void createAConcurrentFlow( int FromArg, int ToArg) { new Runnable() { public void run() { try { new Temp().GenerateNumbers(FromArg, ToArg); } catch (InterruptedException e) { } } }; } ....
  • 36.
  • 37. Creative Commons Sharealike Attributions Noncommercial Programming Concepts – Static Typing int num, sum; // explicit declaration num = 5; // now use the variables sum = 10; sum = sum + num;
  • 38.
  • 39. Creative Commons Sharealike Attributions Noncommercial Programming Concepts – Dynamic Typing foo() { x = 1; x = 'hello'; }
  • 40.
  • 41. Creative Commons Sharealike Attributions Noncommercial Some Real-Life Problems – Prolog vs Java % % Facts % male(hrithik). male(shahrukh). male(salman). male(abhishek). male(akshay). male(aamir). female(diya). female(aishwarya). female(katrina). female(malaika). parent(hrithik,shahrukh). parent(hrithik,salman). parent(hrithik,diya). parent(shahrukh,abhishek). parent(shahrukh,akshay). parent(salman,aishwarya). parent(salman,katrina). parent(salman,aamir). parent(diya,malaika). % % Rules % father(X,Y) :- parent(X,Y), male(X). mother(X,Y) :- parent(X,Y), female(X). grandparent(X,Y) :- parent(X,Z), parent(Z,Y). paternalgrandfather(X,Y) :- father(X,Z), father(Z,Y). sibling(X,Y) :- parent(Z,X), parent(Z,Y). brothers(X,Y) :- sibling(X,Y),male(X),male(Y), (X=Y). % % Queries % cmd: mother(diya,malaika) % Outupt: yes/no cmd: mother(Mother,Child). % Output: lists (mother,child) pair found in facts % according to associations defined
  • 42. Creative Commons Sharealike Attributions Noncommercial Some Real-Life Problems – Statistics
  • 43.
  • 44.
  • 45.
  • 46. Questions??? [email_address] & [email_address] http://directi.com http://careers.directi.com Download slides: http://wiki.directi.com
  • 47. Retrospective!!! [email_address] & [email_address] http://directi.com http://careers.directi.com Download slides: http://wiki.directi.com