CIS 500 Software Foundations Fall September(continued) IS 500, 8 September(continued) 1

Documentos relacionados
Second Exam 13/7/2010

O PRíNCIPE FELIZ E OUTRAS HISTóRIAS (EDIçãO BILíNGUE) (PORTUGUESE EDITION) BY OSCAR WILDE

Como Mudar a Senha do Roteador Pelo IP o.1.1. Configure e Altere a Senha do seu Roteador acessando o IP Acesse o Site e Confira!

Aprendi A Fazer Sexo Na Bíblia (Portuguese Edition)

MySQL: Comece com o principal banco de dados open source do mercado (Portuguese Edition)

PROVA DE EXATAS QUESTÕES EM PORTUGUÊS:

PL/SQL: Domine a linguagem do banco de dados Oracle (Portuguese Edition)

GERENCIAMENTO PELAS DIRETRIZES (PORTUGUESE EDITION) BY VICENTE FALCONI

PMR 5237 Modelagem e Design de Sistemas Discretos em Redes de Petri

Dermatologia Clínica. Guia Colorido Para Diagnostico e Tratamento (Em Portuguese do Brasil)

TEN CATE. HISTOLOGIA ORAL (EM PORTUGUESE DO BRASIL) BY ANTONIO NANCI

DO SILêNCIO DO LAR AO SILêNCIO ESCOLAR: RACISMO, PRECONCEITO E DISCRIMINAçãO NA EDUCAçãO INFANTIL (

O candomblé e seus orixás (Coleção Autoconhecimento) (Portuguese Edition)

BEM-TE-VI. LIVRO INFANTOJUVENIL.: ROMANCE GAY. (PORTUGUESE EDITION) BY MARLI PORTO

ATLAS DE ACUPUNTURA VETERINáRIA. CãES E GATOS (EM PORTUGUESE DO BRASIL) BY CHOO HYUNG KIM

EGAN. FUNDAMENTOS DA TERAPIA RESPIRATÓRIA (EM PORTUGUESE DO BRASIL) BY CRAIG L. SCANLAN

PODER DO ESPIRITO SANTO, O BY BILLY GRAHAM

Compilando o Kernel Linux

Introdução A Delphi Com Banco De Dados Firebird (Portuguese Edition)

PALAVRAS E FRASES CÉLEBRES (PORTUGUESE EDITION) BY ALFREDO CAMPOS

A ENTREVISTA COMPREENSIVA: UM GUIA PARA PESQUISA DE CAMPO (PORTUGUESE EDITION) BY JEAN-CLAUDE KAUFMANN

A ENTREVISTA COMPREENSIVA: UM GUIA PARA PESQUISA DE CAMPO (PORTUGUESE EDITION) BY JEAN-CLAUDE KAUFMANN

Divisão de Engenharia Mecânica. Programa de Pós-Graduação em Engenharia Aeronáutica e Mecânica. Prova de Seleção para Bolsas 1 o semestre de 2014

GUIÃO F. Grupo: Minho. 1º Momento. Intervenientes e Tempos. Descrição das actividades

A oração de Jabez: Alcançando a bênção de Deus (Portuguese Edition)

BR localization: Hotfix 109. Technical documentation Documentação Técnica Version Oct 23, de outubro de 2018

COMPUTAÇÃO E PROGRAMAÇÃO

DIBELS TM. Portuguese Translations of Administration Directions

Comportamento Organizacional: O Comportamento Humano no Trabalho (Portuguese Edition)

ATLAS COLORIDO DE ANATOMIA VETERINáRIA DE EQUINOS (EM PORTUGUESE DO BRASIL) BY STANLEY H. ASHDOWN RAYMOND R. DONE

General Equilibrium Theory

Conversação Para Viagem - Inglês (Michaelis Tour) (Portuguese Edition)

GERENCIAMENTO DA ROTINA DO TRABALHO DO DIA-A-DIA (EM PORTUGUESE DO BRASIL) BY VICENTE FALCONI

Os 7 Hábitos das Pessoas Altamente Eficazes (Portuguese Edition)

O ABC da Fisioterapia Respiratória (Portuguese Edition)

GERENCIAMENTO DA ROTINA DO TRABALHO DO DIA A DIA (PORTUGUESE EDITION) BY VICENTE FALCONI

TEN CATE. HISTOLOGIA ORAL (EM PORTUGUESE DO BRASIL) BY ANTONIO NANCI

O VAZIO DA MáQUINA: NIILISMO E OUTROS ABISMOS (TRILOGIA DO NADA LIVRO 2) (PORTUGUESE EDITION) BY ANDRE CANCIAN

Trabalho de AMSR. Especificação e Verificação de uma Câmara Fotográfica Digital. Problema a Resolver FEUP/MRSC/AMSR MPR. » Problema a concurso

Um olhar que cura: Terapia das doenças espirituais (Portuguese Edition)

ATLAS DE ACUPUNTURA VETERINáRIA. CãES E GATOS (EM PORTUGUESE DO BRASIL) BY CHOO HYUNG KIM

Como testar componentes eletrônicos - volume 1 (Portuguese Edition)

Direito Processual Civil (Coleção Sucesso Concursos Públicos e OAB) (Portuguese Edition)

TDD Desenvolvimento Guiado por Testes (Portuguese Edition)

Prova de Seleção Mestrado LINGUA INGLESA 15/02/2016

Farmacologia na Pratica de Enfermagem (Em Portuguese do Brasil)

Pesquisa Qualitativa do Início ao Fim (Métodos de Pesquisa) (Portuguese Edition)

MANUAL DE MEDICINA INTERNA DE PEQUENOS ANIMAIS (EM PORTUGUESE DO BRASIL) BY RICHARD W. COUTO C. GUILHERMO^NELSON

Bíblia do Obreiro - Almeida Revista e Atualizada: Concordância Dicionário Auxílios Cerimônias (Portuguese Edition)

Dilogo Brasil Livro Texto: Curso Intensivo De Portugues Para Estrangeiros (Dialogo Brasil) (Portuguese Edition)

Meu Filho é Alérgico! E Agora? (Portuguese Edition)

O sistema único de assistência social no Brasil: uma realidade em movimento (Portuguese Edition)

Introdução A Delphi Com Banco De Dados Firebird (Portuguese Edition)

Biossegurança: uma abordagem multidisciplinar (Portuguese Edition)

Vaporpunk - A fazenda-relógio (Portuguese Edition)

CANape/vSignalyzer. Data Mining and Report Examples Offline Analysis V

Vendors Enquiries for RFP 003/2015

Welcome to Lesson A of Story Time for Portuguese

Descrição das actividades

ATLAS DE ACUPUNTURA VETERINáRIA. CãES E GATOS (EM PORTUGUESE DO BRASIL) BY CHOO HYUNG KIM

Livro do Desassossego

and environmental aspects aspectos socioambientais

Meditacao da Luz: O Caminho da Simplicidade

PROJETO DE INTERFACES PARA ÁLGEBRA DE MAPAS EM GEOPROCESSAMENTO NO AMBIENTE SPRING

Course Review for Midterm Exam 1. Cpt S 223 Fall 2010

O Livro do Riso do Menino Maluquinho - Todas as piadas que as crianças ouviram ou contaram no último século (Portuguese Edition)

Guia para Formacao de Analistas de Processos: Gestão Por Processos de Forma Simples (Portuguese Edition)

COMO ESCREVER PARA O ENEM: ROTEIRO PARA UMA REDAçãO NOTA (PORTUGUESE EDITION) BY ARLETE SALVADOR

O Livro dos Espíritos - Tradução Evandro Noleto Bezerra (Portuguese Edition)

Energia dos Chakras, Saúde e Autotransformação (Portuguese Edition)

Ganhar Dinheiro Em Network Marketing (Portuguese Edition)

Curso Completo de Memorização (Portuguese Edition)

Planejamento de comunicação integrada (Portuguese Edition)

HISTOLOGIA E BIOLOGIA CELULAR. UMA INTRODUçãO À PATOLOGIA (EM PORTUGUESE DO BRASIL) BY ABRAHAM L. KIERSZENBAUM

Já Chegou Aos Confins Da Terra. E Agora? (Portuguese Edition)

Reabilitação Neurológica (Em Portuguese do Brasil)

Ética na Propaganda (Portuguese Edition)

GUIA DE CONVERSAçãO PORTUGUêS- ITALIANO E VOCABULáRIO TEMáTICO 3000 PALAVRAS (PORTUGUESE EDITION) BY AND

Poder sem limites - o caminho do sucesso pessoal pela programação neurolinguística

Guião N. Descrição das actividades

PL/SQL: Domine a linguagem do banco de dados Oracle (Portuguese Edition)

COMO ESCREVER PARA O ENEM: ROTEIRO PARA UMA REDAçãO NOTA (PORTUGUESE EDITION) BY ARLETE SALVADOR

BR localization: Hotfix 108. Technical documentation Documentação Técnica Version Oct 16, de outubro de 2018

As 100 melhores piadas de todos os tempos (Portuguese Edition)

Estatística Aplicada: Administração, Economia e Negócios (Portuguese Edition)

Minhas lembranças de Leminski (Portuguese Edition)

Espionagem e Vigilância Eletrônica (Portuguese Edition)

Aula 12 - Correção de erros

GERENCIAMENTO PELAS DIRETRIZES (PORTUGUESE EDITION) BY VICENTE FALCONI

Boids Model Applied to Cell Segregation

ALGEBRA 2 PRACTICE FINAL EXAM

Uma introdução à indecilibidade a forma máxima de complexidade!

Esboços e Sermões Completos para Ocasiões e Datas Especiais: Mensagens Bíblicas para Todas as Datas da Vida Cristã (Portuguese Edition)

Performance and Power Consumption Analysis of Full Adders Designed in 32nm Technology

ATLAS DE ACUPUNTURA VETERINáRIA. CãES E GATOS (EM PORTUGUESE DO BRASIL) BY CHOO HYUNG KIM

MANUAL PRATICO DO PLANO DE PROJETO: UTILIZANDO O PMBOK GUIDE BY RICARDO VIANA VARGAS

Serviços: API REST. URL - Recurso

Transcrição:

CIS 500 Software Foundations Fall 2003 8 September(continued) IS 500, 8 September(continued) 1

Polymorphism This version of issaidtobepolymorphic,becauseitcanbeapplied to many different types of arguments. ( Poly = many, morph = shape.) Notethatthetypeoftheelementsof is (pronounced alpha ). This is a type variable, which can instantiated, each time we apply,by replacing withanytypethatwelike. Theinstancesofthetype include In other words, canberead, isafunctionthattakesalistofelementsofanytype alpha and returns an element of alpha. IS 500, 8 September(continued) 2

A polymorphic IS 500, 8 September(continued) 3

A polymorphic IS 500, 8 September(continued) 4

Polymorphic Whatisthetypeof? IS 500, 8 September(continued) 5

Palindromes Apalindromeisaword,sentence,orothersequencethatreadsthesame forwards and backwards. IS 500, 8 September(continued) 6

map: apply-to-each OCaml has a predefined function that takes a function anda list and produces another list by applying toeachelementof. We ll soonseehowtodefine,butfirstlet slookatsomeexamples. Note that is polymorphic: it works for lists of integers, strings, booleans, etc. IS 500, 8 September(continued) 7

Moreonmap An interesting feature of Forthisreason,wecall isitsfirstargumentisitselfafunction. ahigher-orderfunction. Natural uses for higher-order functions arise frequently in programming. One of OCaml s strengths is that it makes higher-order functions very easytoworkwith. In other languages such as Java, higher-order functions can be(and often are) simulated using objects. IS 500, 8 September(continued) 8

filter Another useful higher-order function is. Whenappliedtoa list andabooleanfunction,itextractsfrom thelistofthose elementsforwhich returns. IS 500, 8 September(continued) 9

Note that, like map, type. is polymorphic it works on lists of any IS 500, 8 September(continued) 10

Defining comespredefinedintheocamlsystem,butthereisnothing magicaboutit wecaneasilydefineourown function with the same behavior. Thetypeof is probably even more polymorphic than you expected! Thelistthatitreturnscanactuallybeofadifferenttypefromits argument: IS 500, 8 September(continued) 11

Defining Similarly, we can define our own thatbehavesthesameas. IS 500, 8 September(continued) 12

Approaches to Typing A strongly typed language prevents programs from accessing private data, corrupting memory, crashing the machine, etc. A weakly typed language does not. A statically typed language performs type-consistency checks at when programs are first entered. A dynamically typed language delays these checks until programs are executed. Weak Strong Dynamic PERL Lisp, Scheme Static C, C++ ML, ADA, Java Strictly speaking, Java should be called mostly static IS 500, 8 September(continued) 13

Practice with Types What are the types of the following functions? IS 500, 8 September(continued) 14

And one more: IS 500, 8 September(continued) 15

Aside: Polymorphism The polymorphism in ML that arises from type parameters is an example ofgenericprogramming. (,,etc.) Aregoodexamplesof generic functions. Different languages support generic programming in different ways... overloading(e.g. parametric polymorphism allows functions to work uniformly over arguments of different types.e.g., ad hoc polymporphism(or overloading) allows an operation to behave in different ways when applied to arguments of different types. There is no such polymorphism in OCaml, but most languages allow some and ). JavaandC++allowoneto extend the overloading of a symbol(e.g. ). Thisform of overloading is a syntactic convenience, but little more. subtype polymporphism allows operations to be defined for collections of types sharing some common structure IS 500, 8 September(continued) 16

e.g.,a its refinements operation might make sense for values of,,,etc. and all IS 500, 8 September(continued) 17

OCaml supports parametric polymorphism in a very general way, and alsosupportssubtyping(thoughweshallnotgettoseethisaspectof OCaml, its support for subtyping is what distinguishes it from other dialects of ML.) It does not allow overloading. Java provides a subtyping as well as moderately powerful overloading, but no parametric polymorphism. (Various Java extensions with parametric polymorphism are under discussion.) Confusingly, the bare term polymorphism is used to refer to parametric polymorphism in the ML community and for subtype polymorphism in the Java community! IS 500, 8 September(continued) 18