Coconut Sandor aguilar.

Slides:



Advertisements
Similar presentations
Introduction to OCaml Slides prepared by Matt Gruskin Some material borrowed from the CIS 500 lecture notes.
Advertisements

1 Scheme and Functional Programming Aaron Bloomfield CS 415 Fall 2005.
Object-Oriented Programming Python. OO Paradigm - Review Three Characteristics of OO Languages –Inheritance It isn’t necessary to build every class from.
More about functions Plus a few random things. 2 Tail recursion A function is said to be tail recursive if the recursive call is the very last thing it.
Tail Recursion. Problems with Recursion Recursion is generally favored over iteration in Scheme and many other languages – It’s elegant, minimal, can.
Map and Fold Building Powerful Abstractions. Hello. I’m Zach, one of Sorin’s students.
CSE (c) S. Tanimoto, 2007 Python Introduction 1 Introduction to Python for Artificial Intelligence Outline: Why Python? Interactive programming,
Introducing the Erlang Language Why Erlang?  Exemplifies the “you can have code and concurrency that is free from side effects…there is no other way”
UNIVERSITY OF SOUTH CAROLINA Department of Computer Science and Engineering Introduction to Functional Programming Notes for CSCE 190 Based on Sebesta,
Lecture 2: Design and Implementation of Lambda Expressions in Java 8 Alfred V. Aho CS E6998-1: Advanced Topics in Programming Languages.
2/28/2008. >>> Overview Arrays in Python – a.k.a. Lists Ranges are Lists Strings vs. Lists Tuples vs. Lists Map-Reduce Lambda Review: Printing to a file.
Tail Recursion. Problems with Recursion Recursion is generally favored over iteration in Scheme and many other languages – It’s elegant, minimal, can.
Functions.
List Comprehensions. Python’s higher-order functions  Python supports higher-order functions that operate on lists similar to Scheme’s >>> def square(x):
Introduction to Functional Programming (SCALA) John Woodward.
Gary MarsdenSlide 1University of Cape Town Functional programming in Clean Gary Marsden Semester 2 – 2000.
Com Functional Programming Higher Order Functions and Computation Patterns (I) Marian Gheorghe Lecture 10 Module homepage Mole &
Functional Languages. Why? Referential Transparency Functions as first class objects Higher level of abstraction Potential for parallel execution.
Haskell. 2 GHC and HUGS Haskell 98 is the current version of Haskell GHC (Glasgow Haskell Compiler, version 7.4.1) is the version of Haskell I am using.
0 REVIEW OF HASKELL A lightening tour in 45 minutes.
CS 152: Programming Language Paradigms February 17 Class Meeting Department of Computer Science San Jose State University Spring 2014 Instructor: Ron Mak.
The building blocks of functional computing data, sequences conditionals recursion CS 121 today List Comprehensions map and applications.
Python functional programming. Functions are first-class objects Functions can be used as any other datatype, eg: Arguments to function Return values.
Compiling Functional Programs Mooly Sagiv Chapter 7
Functions CSE 1310 – Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington 1.
RUBY by Ryan Chase.
Curry A Tasty dish? Haskell Curry!. Curried Functions Currying is a functional programming technique that takes a function of N arguments and produces.
Functional Programming IN NON-FUNCTIONAL LANGUAGES.
Second Order Programming Intro2CS – week 10B 1. Functions are values too 2.
1 PROGRAMMING IN HASKELL An Introduction Based on lecture notes by Graham Hutton The book “Learn You a Haskell for Great Good” (and a few other sources)
Conditional Expressions
Midterm recap Total was 80 points Distribution range
Functions and patterns
A lightening tour in 45 minutes
Expanded Recursive Diagrams OCAML rapid tour, day 2
Main Points of Haskell Functional programming Laziness
Pure Kevin Edelmann.
Haskell Strings and Tuples
Functions, Procedures, and Abstraction
Weaving Abstractions into Workflows
LECTURE 31: INTRO TO FUNCTIONAL PROGRAMMING
Passing Parameters by value
Plus a few random things
CSE341: Programming Languages Lecture 6 Nested Patterns Exceptions Tail Recursion Dan Grossman Autumn 2018.
CSE341: Programming Languages Section 3 Function Patterns Tail Recursion Winter 2018.
PROGRAMMING IN HASKELL
CSCE 314: Programming Languages Dr. Dylan Shell
Lisp, Then and Now.
Plus a few random things
CSE341: Programming Languages Lecture 6 Nested Patterns Exceptions Tail Recursion Zach Tatlock Winter 2018.
(more) Python.
CSE 3302 Programming Languages
(Computer fundamental Lab)
Functions and patterns
ENIAC – the first computer
Plus a few random things
Functional Programming
Higher-Order Functions in Haskell
Functional Programming and Haskell
CISC101 Reminders Assignment 3 due today.
PROGRAMMING IN HASKELL
Plus a few random things
CSE341: Programming Languages Lecture 6 Nested Patterns Exceptions Tail Recursion Dan Grossman Spring 2019.
Plus a few random things
Plus a few random things
CSE341: Programming Languages Lecture 6 Nested Patterns Exceptions Tail Recursion Dan Grossman Autumn 2017.
Functional Programming and Haskell
Presentation transcript:

Coconut Sandor aguilar

What is Coconut? Open source derivative of Python Introduces friendlier functional programming to Python by adding built-in syntactical support Compiles to Python Unique in that it is Python version agnostic Works ALMOST the same on any version of Python “

Why Coconut? “… if you look at the top 20 most popular programming languages, not a single one is functional. But there are functional alternatives to a lot of them. Java has Scala. C# has F#. Python has ... nothing.” - Evan Hubinger, creator of Coconut

Pipeline and Lambdas Pipeline style programming Prettier Lambdas “Hello, World!” |> print instead of print(“Hello, World!) In Coconut for multiple argument: def sq(x) = x**2 (1, 2) |*> (+) |> sq |> print In Python: import operator def sq(x): return x**2 print(sq(operator.add(1, 2))) Prettier Lambdas (x) -> x**2 instead of lamda x: x**2 In Python: map(lambda x: x * x, [0, 1, 2, 3, 4]) In Coconut: map(x -> x*x, [0, 1, 2, 3, 4]) |> list

Partial Application and Infix Partial Application (i.e. currying) In Coconut: range(5) |> map$((x) -> x*2) |> list produces [0, 2, 4, 6, 8] In Python: import functools print(map(functools.partial(lambda x: x*2), range(5))) Infix notation def a `mod` b = a % b 5 ‘mod’ 3 == 2

Lazy Lists and Pattern Matching In Coconut: (| range(100) |> list |) In Python: Need to import python package Destructing Assignment {”list”: [0] + rest} = {“list”: [0, 1, 2, 3]} rest = [1, 2, 3] Pattern matching match [head] + tail in [0, 1, 2, 3]: print(head, tail) produces [1, 2, 3] 0

And More Parallel programming Tail recursion optimization range(10) |> parallel_map$( (**)$(2)) |> list produces [1, 2, 4, 8, 16, 32, 64, 128, 256, 512] Tail recursion optimization

Further Information Coconut Documentation: http://coconut.readthedocs.io/en/master Coconut Tutorial: http://coconut.readthedocs.io/en/master/HELP.html Coconut Github repository: https://github.com/evhub/coconut