Notes on Functional Programming with Haskell

Total Page:16

File Type:pdf, Size:1020Kb

Notes on Functional Programming with Haskell Notes on Functional Programming with Haskell H. Conrad Cunningham [email protected] Multiparadigm Software Architecture Group Department of Computer and Information Science University of Mississippi 201 Weir Hall University, Mississippi 38677 USA Fall Semester 2014 Copyright c 1994, 1995, 1997, 2003, 2007, 2010, 2014 by H. Conrad Cunningham Permission to copy and use this document for educational or research purposes of a non-commercial nature is hereby granted provided that this copyright notice is retained on all copies. All other rights are reserved by the author. H. Conrad Cunningham, D.Sc. Professor and Chair Department of Computer and Information Science University of Mississippi 201 Weir Hall University, Mississippi 38677 USA [email protected] PREFACE TO 1995 EDITION I wrote this set of lecture notes for use in the course Functional Programming (CSCI 555) that I teach in the Department of Computer and Information Science at the Uni- versity of Mississippi. The course is open to advanced undergraduates and beginning graduate students. The first version of these notes were written as a part of my preparation for the fall semester 1993 offering of the course. This version reflects some restructuring and revision done for the fall 1994 offering of the course|or after completion of the class. For these classes, I used the following resources: Textbook { Richard Bird and Philip Wadler. Introduction to Functional Program- ming, Prentice Hall International, 1988 [2]. These notes more or less cover the material from chapters 1 through 6 plus selected material from chapters 7 through 9. Software { Gofer interpreter version 2.30 (2.28 in 1993) written by Mark P. Jones, available via anonymous FTP from directory pub/haskell/gofer at the Inter- net site nebula.cs.yale.edu. Gofer is an interpreter for a dialect of the \lazy" functional programming lan- guage Haskell. This interpreter was available on both MS-DOS-based PC- compatibles, 486-based systems executing FreeBSD (\UNIX"), and other UNIX systems. Manual { Mark P. Jones. An Introduction to Gofer (Version 2.20), tutorial manual distributed as a part of the Gofer system [15]. In addition to the Bird and Wadler textbook and the Gofer manual, I used the following sources in the preparation of these lecture notes: • Paul Hudak and Joseph H. Fasel. \A Gentle Introduction to Haskell", ACM SIGPLAN NOTICES, Vol. 27, No. 5, May 1992 [12]. • Paul Hudak, Simon Peyton Jones, and Philip Wadler. \Report on the Pro- gramming Language Haskell: A Non-strict, Purely Functional Language", ACM SIGPLAN NOTICES, Vol. 27, No. 5, May 1992 [13]. • E. P. Wentworth. Introduction to Functional Programming using RUFL, De- partment of Computer Science, Rhodes University, Grahamstown, South Africa, August 1990 [22]. This is a good tutorial and manual for the Rhodes University Functional Lan- guage (RUFL), a Haskell-like language developed by Wentworth. I used RUFL for two previous offerings of my functional programming course, but switched to iii Gofer for the fall semester 1993 offering. My use this source was indirect|via my handwritten lecture notes for the previous versions of the class. • Paul Hudak. \Conception, Evolution, and Application of Functional Program- ming Languages", ACM Computing Surveys, Vol. 21, No. 3, pages 359{411, September 1989 [11]. • Rob Hoogerwoord. The Design of Functional Programs: A Calculational Ap- proach, Doctoral Dissertation, Eindhoven Technical University, Eindhoven, The Netherlands, 1989 [10]. • A. J. T. Davie An Introduction to Functional Programming Systems Using Haskell, Cambridge University Press, 1992 [7]. • Anthony J. Field and Peter G. Harrison. Functional Programming, Addison Wesley, 1988 [8]. This book uses the \eager" functional language Hope. • J. Hughes. \Why Functional Programming Matters," The Computer Journal, Vol. 32, No. 2, pages 98{107, 1989 [14]. Although the Bird and Wadler textbook is excellent, I decided to supplement the book with these notes for several reasons: • I wanted to use Gofer/Haskell language concepts, terminology, and example programs in my class presentations and homework exercises. Although close to Haskell, the language in Bird and Wadler differs from Gofer and Haskell somewhat in both syntax and semantics. • Unlike the stated audience of the Bird and Wadler textbook, my students usu- ally have several years of experience in programming using traditional languages like Pascal, C, or Fortran. This is both an advantage and a disadvantage. On the one hand, they have programming experience and programming language familiarity on which I can build. On the other hand, they have an imperative mindset that sometimes is resistant to the declarative programming approach. I tried to take both into account as I drafted these notes. • Because of a change in the language used from RUFL to Gofer, I needed to rewrite my lecture notes in 1993 anyway. Thus I decided to invest a bit more effort and make them available in this form. (I expected about 25% more effort, but it probably took about 100% more effort. :-) • The publisher of the Bird and Wadler textbook told me a few weeks before my 1993 class began that the book would not be available until halfway through the semester. Fortunately, the books arrived much earlier than predicted. In the future, I hope that these notes will give me a \backup" should the book not be available when I need it. iv Overall, I was reasonably satisfied with the 1993 draft of the notes. However, I did not achieve all that I wanted. Unfortunately, other obligations did not allow me to substantially address these issues in the current revision. I hope to address the following shortcomings in any future revision of the notes. • I originally wanted the notes to introduce formal program proof and synthesis concepts earlier and in a more integrated way than these notes currently do. But I did not have sufficient time to reorganize the course and develop the new materials needed. Also the desire to give nontrivial programming exercises led me to focus on the language concepts and features and informal programming techniques during the first half of the course. • Gofer/Haskell is a relatively large language with many features. In 1993 I spent more time covering the language features than I initially planned to do. In the 1994 class I reordered a few of the topics, but still spent more time on language features. For future classes I need to rethink the choice and ordering of the language features presented. Perhaps a few of the language features should be omitted in an introductory course. • Still yet there are a few important features that I did not cover. In particular, I did not discuss the more sophisticated features of the type system in any detail (e.g., type classes, instances, and overloading). • I did not cover all the material that I have in covered in one or both of the previous versions of the course (e.g., cyclic structures, abstract data types, the eight queens problem, and applications of trees). 1997 Note: The 1997 revision is limited to the correction of a few errors. The spring semester 1997 class is using the new Hugs interpreter rather than Gofer and the text- book Haskell: The Craft of Functional Programming by Simon Thompson (Addison- Wesley, 1996). 2014 Note: The 2014 revision seeks primarily to update these Notes to use Haskell 2010 and the Haskell Platform (i.e., GHC and GHCi). The focus is on chapters 3, 5, 6, 7, 8, and 10, which are being used in teaching a Haskell-based functional programming module in CSci 450 (Organization of Programming Languages). v Acknowledgements I thank the many students in the CSCI 555 classes who helped me find many typo- graphical and presentation errors in the working drafts of these notes. I also thank those individuals at other institutions who have examined these notes and suggested improvements. I thank Diana Cunningham, my wife, for being patient with all the late nights of work that writing these notes required. The preparation of this document was supported by the National Science Foundation under Grant CCR-9210342 and by the Department of Computer and Information Science at the University of Mississippi. vi Contents 1 INTRODUCTION 1 1.1 Course Overview . 1 1.2 Excerpts from Backus' 1977 Turing Award Address . 2 1.3 Programming Language Paradigms . 5 1.4 Reasons for Studying Functional Programming . 6 1.5 Objections Raised Against Functional Programming . 11 2 FUNCTIONS AND THEIR DEFINITIONS 13 2.1 Mathematical Concepts and Terminology . 13 2.2 Function Definitions . 15 2.3 Mathematical Induction over Natural Numbers . 15 3 FIRST LOOK AT HASKELL 17 4 USING THE INTERPRETER 23 5 HASKELL BASICS 25 5.1 Built-in Types . 25 5.2 Programming with List Patterns . 30 5.2.1 Summation of a list (sumlist).................. 30 5.2.2 Length of a list (length').................... 32 5.2.3 Removing adjacent duplicates (remdups) . 32 5.2.4 More example patterns . 34 5.3 Infix Operations . 35 5.4 Recursive Programming Styles . 36 5.4.1 Appending lists (++) ....................... 36 5.4.2 Reversing a list (rev)....................... 37 5.4.3 Recursion Terminology . 38 5.4.4 Tail recursive reverse (reverse') . 39 vii 5.4.5 Local definitions (let and where) . 40 5.4.6 Fibonacci numbers . 41 5.5 More List Operations . 43 5.5.1 Element selection (!!)...................... 43 5.5.2 List-breaking operations (take and drop) . 43 5.5.3 List-combining operations (zip) . 44 5.6 Rational Arithmetic Package . 44 5.7 Exercises . 48 6 HIGHER-ORDER FUNCTIONS 55 6.1 Maps . 55 6.2 Filters . 57 6.3 Folds . 58 6.4 Strictness . 61 6.5 Currying and Partial Application . 62 6.6 Operator Sections . 64 6.7 Combinators . 65 6.8 Functional Composition . 66 6.9 Lambda Expressions .
Recommended publications
  • Structure Interpretation of Text Formats
    1 1 Structure Interpretation of Text Formats 2 3 SUMIT GULWANI, Microsoft, USA 4 VU LE, Microsoft, USA 5 6 ARJUN RADHAKRISHNA, Microsoft, USA 7 IVAN RADIČEK, Microsoft, Austria 8 MOHAMMAD RAZA, Microsoft, USA 9 Data repositories often consist of text files in a wide variety of standard formats, ad-hoc formats, aswell 10 mixtures of formats where data in one format is embedded into a different format. It is therefore a significant 11 challenge to parse these files into a structured tabular form, which is important to enable any downstream 12 data processing. 13 We present Unravel, an extensible framework for structure interpretation of ad-hoc formats. Unravel 14 can automatically, with no user input, extract tabular data from a diverse range of standard, ad-hoc and 15 mixed format files. The framework is also easily extensible to add support for previously unseen formats, 16 and also supports interactivity from the user in terms of examples to guide the system when specialized data extraction is desired. Our key insight is to allow arbitrary combination of extraction and parsing techniques 17 through a concept called partial structures. Partial structures act as a common language through which the file 18 structure can be shared and refined by different techniques. This makes Unravel more powerful than applying 19 the individual techniques in parallel or sequentially. Further, with this rule-based extensible approach, we 20 introduce the novel notion of re-interpretation where the variety of techniques supported by our system can 21 be exploited to improve accuracy while optimizing for particular quality measures or restricted environments.
    [Show full text]
  • The Marriage of Effects and Monads
    The Marriage of Effects and Monads PHILIP WADLER Avaya Labs and PETER THIEMANN Universit¨at Freiburg Gifford and others proposed an effect typing discipline to delimit the scope of computational ef- fects within a program, while Moggi and others proposed monads for much the same purpose. Here we marry effects to monads, uniting two previously separate lines of research. In partic- ular, we show that the type, region, and effect system of Talpin and Jouvelot carries over di- rectly to an analogous system for monads, including a type and effect reconstruction algorithm. The same technique should allow one to transpose any effect system into a corresponding monad system. Categories and Subject Descriptors: D.3.1 [Programming Languages]: Formal Definitions and Theory; F.3.2 [Logics and Meanings of Programs]: Semantics of Programming Languages— Operational semantics General Terms: Languages, Theory Additional Key Words and Phrases: Monad, effect, type, region, type reconstruction 1. INTRODUCTION Computational effects, such as state or continuations, are powerful medicine. If taken as directed they may cure a nasty bug, but one must be wary of the side effects. For this reason, many researchers in computing seek to exploit the benefits of computational effects while delimiting their scope. Two such lines of research are the effect typing discipline, proposed by Gifford and Lucassen [Gifford and Lucassen 1986; Lucassen 1987], and pursued by Talpin and Jouvelot [Talpin and Jouvelot 1992, 1994; Talpin 1993] among others, and the use of monads, proposed by Moggi [1989, 1990], and pursued by Wadler [1990, 1992, 1993, 1995] among others. Effect systems are typically found in strict languages, such as FX [Gifford et al.
    [Show full text]
  • Lecture 4. Higher-Order Functions Functional Programming
    Lecture 4. Higher-order functions Functional Programming [Faculty of Science Information and Computing Sciences] 0 I function call and return as only control-flow primitive I no loops, break, continue, goto I (almost) unique types I no inheritance hell I high-level declarative data-structures I no explicit reference-based data structures Goal of typed purely functional programming Keep programs easy to reason about by I data-flow only through function arguments and return values I no hidden data-flow through mutable variables/state [Faculty of Science Information and Computing Sciences] 1 I (almost) unique types I no inheritance hell I high-level declarative data-structures I no explicit reference-based data structures Goal of typed purely functional programming Keep programs easy to reason about by I data-flow only through function arguments and return values I no hidden data-flow through mutable variables/state I function call and return as only control-flow primitive I no loops, break, continue, goto [Faculty of Science Information and Computing Sciences] 1 I high-level declarative data-structures I no explicit reference-based data structures Goal of typed purely functional programming Keep programs easy to reason about by I data-flow only through function arguments and return values I no hidden data-flow through mutable variables/state I function call and return as only control-flow primitive I no loops, break, continue, goto I (almost) unique types I no inheritance hell [Faculty of Science Information and Computing Sciences] 1 Goal
    [Show full text]
  • Functional Languages
    Functional Programming Languages (FPL) 1. Definitions................................................................... 2 2. Applications ................................................................ 2 3. Examples..................................................................... 3 4. FPL Characteristics:.................................................... 3 5. Lambda calculus (LC)................................................. 4 6. Functions in FPLs ....................................................... 7 7. Modern functional languages...................................... 9 8. Scheme overview...................................................... 11 8.1. Get your own Scheme from MIT...................... 11 8.2. General overview.............................................. 11 8.3. Data Typing ...................................................... 12 8.4. Comments ......................................................... 12 8.5. Recursion Instead of Iteration........................... 13 8.6. Evaluation ......................................................... 14 8.7. Storing and using Scheme code ........................ 14 8.8. Variables ........................................................... 15 8.9. Data types.......................................................... 16 8.10. Arithmetic functions ......................................... 17 8.11. Selection functions............................................ 18 8.12. Iteration............................................................. 23 8.13. Defining functions ...........................................
    [Show full text]
  • Higher-Order Functions 15-150: Principles of Functional Programming – Lecture 13
    Higher-order Functions 15-150: Principles of Functional Programming { Lecture 13 Giselle Reis By now you might feel like you have a pretty good idea of what is going on in functional program- ming, but in reality we have used only a fragment of the language. In this lecture we see what more we can do and what gives the name functional to this paradigm. Let's take a step back and look at ML's typing system: we have basic types (such as int, string, etc.), tuples of types (t*t' ) and functions of a type to a type (t ->t' ). In a grammar style (where α is a basic type): τ ::= α j τ ∗ τ j τ ! τ What types allowed by this grammar have we not used so far? Well, we could, for instance, have a function below a tuple. Or even a function within a function, couldn't we? The following are completely valid types: int*(int -> int) int ->(int -> int) (int -> int) -> int The first one is a pair in which the first element is an integer and the second one is a function from integers to integers. The second one is a function from integers to functions (which have type int -> int). The third type is a function from functions to integers. The two last types are examples of higher-order functions1, i.e., a function which: • receives a function as a parameter; or • returns a function. Functions can be used like any other value. They are first-class citizens. Maybe this seems strange at first, but I am sure you have used higher-order functions before without noticing it.
    [Show full text]
  • The Machine That Builds Itself: How the Strengths of Lisp Family
    Khomtchouk et al. OPINION NOTE The Machine that Builds Itself: How the Strengths of Lisp Family Languages Facilitate Building Complex and Flexible Bioinformatic Models Bohdan B. Khomtchouk1*, Edmund Weitz2 and Claes Wahlestedt1 *Correspondence: [email protected] Abstract 1Center for Therapeutic Innovation and Department of We address the need for expanding the presence of the Lisp family of Psychiatry and Behavioral programming languages in bioinformatics and computational biology research. Sciences, University of Miami Languages of this family, like Common Lisp, Scheme, or Clojure, facilitate the Miller School of Medicine, 1120 NW 14th ST, Miami, FL, USA creation of powerful and flexible software models that are required for complex 33136 and rapidly evolving domains like biology. We will point out several important key Full list of author information is features that distinguish languages of the Lisp family from other programming available at the end of the article languages and we will explain how these features can aid researchers in becoming more productive and creating better code. We will also show how these features make these languages ideal tools for artificial intelligence and machine learning applications. We will specifically stress the advantages of domain-specific languages (DSL): languages which are specialized to a particular area and thus not only facilitate easier research problem formulation, but also aid in the establishment of standards and best programming practices as applied to the specific research field at hand. DSLs are particularly easy to build in Common Lisp, the most comprehensive Lisp dialect, which is commonly referred to as the “programmable programming language.” We are convinced that Lisp grants programmers unprecedented power to build increasingly sophisticated artificial intelligence systems that may ultimately transform machine learning and AI research in bioinformatics and computational biology.
    [Show full text]
  • Functional Programming Laboratory 1 Programming Paradigms
    Intro 1 Functional Programming Laboratory C. Beeri 1 Programming Paradigms A programming paradigm is an approach to programming: what is a program, how are programs designed and written, and how are the goals of programs achieved by their execution. A paradigm is an idea in pure form; it is realized in a language by a set of constructs and by methodologies for using them. Languages sometimes combine several paradigms. The notion of paradigm provides a useful guide to understanding programming languages. The imperative paradigm underlies languages such as Pascal and C. The object-oriented paradigm is embodied in Smalltalk, C++ and Java. These are probably the paradigms known to the students taking this lab. We introduce functional programming by comparing it to them. 1.1 Imperative and object-oriented programming Imperative programming is based on a simple construct: A cell is a container of data, whose contents can be changed. A cell is an abstraction of a memory location. It can store data, such as integers or real numbers, or addresses of other cells. The abstraction hides the size bounds that apply to real memory, as well as the physical address space details. The variables of Pascal and C denote cells. The programming construct that allows to change the contents of a cell is assignment. In the imperative paradigm a program has, at each point of its execution, a state represented by a collection of cells and their contents. This state changes as the program executes; assignment statements change the contents of cells, other statements create and destroy cells. Yet others, such as conditional and loop statements allow the programmer to direct the control flow of the program.
    [Show full text]
  • Think Python
    Think Python How to Think Like a Computer Scientist 2nd Edition, Version 2.2.18 Think Python How to Think Like a Computer Scientist 2nd Edition, Version 2.2.18 Allen Downey Green Tea Press Needham, Massachusetts Copyright © 2015 Allen Downey. Green Tea Press 9 Washburn Ave Needham MA 02492 Permission is granted to copy, distribute, and/or modify this document under the terms of the Creative Commons Attribution-NonCommercial 3.0 Unported License, which is available at http: //creativecommons.org/licenses/by-nc/3.0/. The original form of this book is LATEX source code. Compiling this LATEX source has the effect of gen- erating a device-independent representation of a textbook, which can be converted to other formats and printed. http://www.thinkpython2.com The LATEX source for this book is available from Preface The strange history of this book In January 1999 I was preparing to teach an introductory programming class in Java. I had taught it three times and I was getting frustrated. The failure rate in the class was too high and, even for students who succeeded, the overall level of achievement was too low. One of the problems I saw was the books. They were too big, with too much unnecessary detail about Java, and not enough high-level guidance about how to program. And they all suffered from the trap door effect: they would start out easy, proceed gradually, and then somewhere around Chapter 5 the bottom would fall out. The students would get too much new material, too fast, and I would spend the rest of the semester picking up the pieces.
    [Show full text]
  • Reversible Programming with Negative and Fractional Types
    9 A Computational Interpretation of Compact Closed Categories: Reversible Programming with Negative and Fractional Types CHAO-HONG CHEN, Indiana University, USA AMR SABRY, Indiana University, USA Compact closed categories include objects representing higher-order functions and are well-established as models of linear logic, concurrency, and quantum computing. We show that it is possible to construct such compact closed categories for conventional sum and product types by defining a dual to sum types, a negative type, and a dual to product types, a fractional type. Inspired by the categorical semantics, we define a sound operational semantics for negative and fractional types in which a negative type represents a computational effect that “reverses execution flow” and a fractional type represents a computational effect that“garbage collects” particular values or throws exceptions. Specifically, we extend a first-order reversible language of type isomorphisms with negative and fractional types, specify an operational semantics for each extension, and prove that each extension forms a compact closed category. We furthermore show that both operational semantics can be merged using the standard combination of backtracking and exceptions resulting in a smooth interoperability of negative and fractional types. We illustrate the expressiveness of this combination by writing a reversible SAT solver that uses back- tracking search along freshly allocated and de-allocated locations. The operational semantics, most of its meta-theoretic properties, and all examples are formalized in a supplementary Agda package. CCS Concepts: • Theory of computation → Type theory; Abstract machines; Operational semantics. Additional Key Words and Phrases: Abstract Machines, Duality of Computation, Higher-Order Reversible Programming, Termination Proofs, Type Isomorphisms ACM Reference Format: Chao-Hong Chen and Amr Sabry.
    [Show full text]
  • Diabetes Care Diagnostics Diagnostics Diagnostics (RDC) (RPD) (RMD) (RTD)
    Committed to innovation and growth Roland Diggelmann, COO Roche Diagnostics UBS Best of Switzerland, Wolfsberg September 19, 2013 HY 2013 Group Results Diagnostics Overview & Strategy HY 2013 Companion Diagnostics Outlook HY 2013: Roche Group highlights HY 2013 performance • Strong Pharma performance, driven by US; solid growth for Diagnostics • 12% core EPS growth1, driven largely by strong underlying business • Solid operating free cash flow (+4%1) Innovation • Move into phase III: Bcl2 inhibitor and anti-PDL1 • Data read-outs for potential phase III decisions: etrolizumab and anti-factor D • Positive CHMP recommendation for Herceptin SC • Discontinued: aleglitazar and GA201 3 1 CER=Constant Exchange Rates HY 2013: Strong sales momentum continues HY 2013 HY 2012 Change in % CHF bn CHF bn CHF CER Pharmaceuticals Division 18.2 17.4 4 6 Diagnostics Division 5.1 5.0 2 3 Roche Group 23.3 22.4 4 5 4 CER=Constant Exchange Rates HY 2013 Group Results Diagnostics Overview & Strategy HY 2013 Companion Diagnostics Outlook In-Vitro Diagnostics market overview Large and growing market; Roche is market leader Market share Market size USD 50 bn Roche Professional Diagnostics 20% Others 39% Molecular Diagnostics 11% Abbott Tissue Diagnostics 10% 3% Siemens Diabetes Monitoring Biomerieux 8% 8% Danaher J&J 6 Source: Roche Analysis, Company reports for 2012 validated by an independent IVD consultancy Overview of Roche Diagnostics New reporting structure In Vitro Diagnostics & Life Sciences Professional Molecular Tissue Diabetes Care Diagnostics Diagnostics
    [Show full text]
  • Natural Domain of a Function • Range Calculations Table of Contents (Continued)
    ~ THE UNIVERSITY OF AKRON w Mathematics and Computer Science calculus Article: Functions menu Directory • Table of Contents • Begin tutorial on Functions • Index Copyright c 1995{1998 D. P. Story Last Revision Date: 11/6/1998 Functions Table of Contents 1. Introduction 2. The Concept of a Function 2.1. Constructing Functions • The Use of Algebraic Expressions • Piecewise Definitions • Descriptive or Conceptual Methods 2.2. Evaluation Issues • Numerical Evaluation • Symbolic Evalulation 2.3. What's in a Name • The \Standard" Way • Functions Named by the Depen- dent Variable • Descriptive Naming • Famous Functions 2.4. Models for Functions • A Function as a Mapping • Venn Diagram of a Function • A Function as a Black Box 2.5. Calculating the Domain and Range • The Natural Domain of a Function • Range Calculations Table of Contents (continued) 2.6. Recognizing Functions • Interpreting the Terminology • The Vertical Line Test 3. Graphing: First Principles 4. Methods of Combining Functions 4.1. The Algebra of Functions 4.2. The Composition of Functions 4.3. Shifting and Rescaling • Horizontal Shifting • Vertical Shifting • Rescaling 5. Classification of Functions • Polynomial Functions • Rational Functions • Algebraic Functions 1. Introduction In the world of Mathematics one of the most common creatures en- countered is the function. It is important to understand the idea of a function if you want to gain a thorough understanding of Calculus. Science concerns itself with the discovery of physical or scientific truth. In a portion of these investigations, researchers (or engineers) attempt to discern relationships between physical quantities of interest. There are many ways of interpreting the meaning of the word \relation- ships," but in Calculus we are most often concerned with functional relationships.
    [Show full text]
  • False Dilemma Wikipedia Contents
    False dilemma Wikipedia Contents 1 False dilemma 1 1.1 Examples ............................................... 1 1.1.1 Morton's fork ......................................... 1 1.1.2 False choice .......................................... 2 1.1.3 Black-and-white thinking ................................... 2 1.2 See also ................................................ 2 1.3 References ............................................... 3 1.4 External links ............................................. 3 2 Affirmative action 4 2.1 Origins ................................................. 4 2.2 Women ................................................ 4 2.3 Quotas ................................................. 5 2.4 National approaches .......................................... 5 2.4.1 Africa ............................................ 5 2.4.2 Asia .............................................. 7 2.4.3 Europe ............................................ 8 2.4.4 North America ........................................ 10 2.4.5 Oceania ............................................ 11 2.4.6 South America ........................................ 11 2.5 International organizations ...................................... 11 2.5.1 United Nations ........................................ 12 2.6 Support ................................................ 12 2.6.1 Polls .............................................. 12 2.7 Criticism ............................................... 12 2.7.1 Mismatching ......................................... 13 2.8 See also
    [Show full text]