Find Jobs
Hire Freelancers

Assignment #6: Lazy Evaluation and Logic Programming in ML

$10-30 USD

완료함
게시됨 약 9년 전

$10-30 USD

제출할때 지불됩니다
Problem 1. Consider the following representation of a polymorphically typed infinite list in ML: datatype 'a inf_list = lcons of 'a * (unit -> 'a inf_list) The above datatype assumes the use of a ‘thunk’ as part of the infinite list representation – hence the presence of the type (unit -> 'a inf_list) in the representation. Consider strings of the form: “Lf.Lx.(f x)” “Lf.Lx.(f (f x))” “Lf.Lx.(f (f (f x)))” “Lf.Lx.(f (f (f (f x))))” “Lf.Lx.(f (f (f (f (f x)))))” … These strings represent the numbers 1, 2, 3, 4, 5, … in the pure lambda-calculus. Here, L stands for λ. Each string is called a Church numeral – in honor of Alonzo Church who invented the λ-calculus. a. Define a function church: string -> string inf_list which generates an infinite list of Church numerals starting from 1. The input to the function church is a string “x”. b. Define a function zip: 'a inf_list * 'b inf_list -> ('a * 'b) inf_list which takes two infinite lists, pairs up the corresponding elements, and produces an output infinite list. Test out church and zip by executing the following “main” program: fun nums(n) = let fun thk() = nums(n+1) in lcons(n, thk) end; fun take(0, _) = [] | take(n, lcons(h, thk)) = h :: take(n-1, thk()); let val l1 = nums(1); val l2 = church("x") in take(5, zip(ll,l2)) end; Submit one file called [login to view URL] with the datatype inf_list and all relevant definitions.
프로젝트 ID: 7622858

프로젝트 정보

제안서 1개
원격근무 프로젝트
활동 중 9년 전

돈을 좀 벌 생각이십니까?

프리랜서 입찰의 이점

예산 및 기간 설정
작업 결과에 대한 급여 수급
제안의 개요를 자세히 쓰세요
무료로 프로젝트에 신청하고 입찰할 수 있습니다
프로젝트를 수여된 사용자:
사용자 아바타
I can do this task but I think you should try to do it yourself before you hire someone :) -----------------------------------------------------
$10 USD 1일에
5.0 (6 건의 리뷰)
2.6
2.6

고객에 대한 정보

국기 (UNITED STATES)
kenmore, United States
5.0
4
결제 수단 확인
4월 28, 2015부터 회원입니다

고객 확인

감사합니다! 무료 크레딧을 신청할 수 있는 링크를 이메일로 보내드렸습니다.
이메일을 보내는 동안 문제가 발생했습니다. 다시 시도해 주세요.
등록 사용자 전체 등록 건수(일자리)
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
미리 보기 화면을 준비 중...
위치 정보 관련 접근권이 허용되었습니다.
고객님의 로그인 세션이 만료되어, 자동으로 로그아웃 처리가 되었습니다. 다시 로그인하여 주십시오.