Scheme Functional Programming Language CSC 337 Concepts of Programming Languages Qassim University College of Computer –IT department Ms.Sadaf Ambreen Abbasi. Reham AL blihed Muna AL rajhi
Outline • About Scheme programming language • A Simple Idea of Scheme Program • Type Primitive Numeric Functions • Type Predicates • General Example of Scheme Language
About Scheme programming language Scheme • is primarily a functional programming language. It shares many characteristics with other members of the Lisp programming language family. Scheme's very simple syntax. • The Scheme language, which is a dialect of LISP, was developed in the mid-1970s.
A Simple Idea of Scheme Program • Some of the differences between Scheme program and C program. CScheme (2 + 3 + 4)(+ 2 3 4)Arithmetic operations ((2 * 3) + (4 * 5))(+ (* 2 3) (* 4 5))Arithmetic operations int sq(int x) { return (x * x) }(define (sq x) (* x x))Function
Type Primitive Numeric Functions : • Scheme includes primitive functions for the basic arithmetic operations. These are +, −, *, and /, for add, subtract, multiply, and divide. • Expressions are written in the form (function_name arguments) Example Expression with Parameter & without Parameter Example of numeric function:
Type Predicates Functions. • A Rredicate Functions is a boolean functions (some representation of either true or false)
General Example of Scheme Language • Example: using special form cond
General Example of Scheme Language Power • The Power Function use mathematical induction and then translate that definition using recursion. Exponentiation (assume m ≠0) m^0 = 1 m^n = m • m^n-1 for n>0 Example:
General Example of Scheme Language • Max of three number Example:
General Example of Scheme Language • Categorize • Categorize is function to check if number positive or negative or zero.
General Example of Scheme Language • Sum of the members of a list • Parameter: a list of numbers. • Result: the sum of all the numbers in the list. Example:
General Example of Scheme Language • Length • Example: • The recursion used in length is called "cdr-recursion". • –At each step, a shorter list is passed to the next function call.
General Example of Scheme Language • Filter • Filter function built-in scheme, which takes a predicate and a list and returns those elements of the list for which the predicate is true. Example:

Scheme Programming Language

  • 1.
    Scheme Functional ProgrammingLanguage CSC 337 Concepts of Programming Languages Qassim University College of Computer –IT department Ms.Sadaf Ambreen Abbasi. Reham AL blihed Muna AL rajhi
  • 2.
    Outline • About Schemeprogramming language • A Simple Idea of Scheme Program • Type Primitive Numeric Functions • Type Predicates • General Example of Scheme Language
  • 3.
    About Scheme programminglanguage Scheme • is primarily a functional programming language. It shares many characteristics with other members of the Lisp programming language family. Scheme's very simple syntax. • The Scheme language, which is a dialect of LISP, was developed in the mid-1970s.
  • 4.
    A Simple Ideaof Scheme Program • Some of the differences between Scheme program and C program. CScheme (2 + 3 + 4)(+ 2 3 4)Arithmetic operations ((2 * 3) + (4 * 5))(+ (* 2 3) (* 4 5))Arithmetic operations int sq(int x) { return (x * x) }(define (sq x) (* x x))Function
  • 5.
    Type Primitive NumericFunctions : • Scheme includes primitive functions for the basic arithmetic operations. These are +, −, *, and /, for add, subtract, multiply, and divide. • Expressions are written in the form (function_name arguments) Example Expression with Parameter & without Parameter Example of numeric function:
  • 6.
    Type Predicates Functions. •A Rredicate Functions is a boolean functions (some representation of either true or false)
  • 7.
    General Example ofScheme Language • Example: using special form cond
  • 8.
    General Example ofScheme Language Power • The Power Function use mathematical induction and then translate that definition using recursion. Exponentiation (assume m ≠0) m^0 = 1 m^n = m • m^n-1 for n>0 Example:
  • 9.
    General Example ofScheme Language • Max of three number Example:
  • 10.
    General Example ofScheme Language • Categorize • Categorize is function to check if number positive or negative or zero.
  • 11.
    General Example ofScheme Language • Sum of the members of a list • Parameter: a list of numbers. • Result: the sum of all the numbers in the list. Example:
  • 12.
    General Example ofScheme Language • Length • Example: • The recursion used in length is called "cdr-recursion". • –At each step, a shorter list is passed to the next function call.
  • 13.
    General Example ofScheme Language • Filter • Filter function built-in scheme, which takes a predicate and a list and returns those elements of the list for which the predicate is true. Example: