Adds exercises from week 5

This commit is contained in:
julien lengrand-lambert
2017-04-14 11:10:04 +02:00
parent ed44fbc203
commit c89d2c58fc
3 changed files with 13 additions and 3 deletions

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id="courses-build" external.linked.project.path="$MODULE_DIR$/../../project" external.root.project.path="$MODULE_DIR$/../.." external.system.id="SBT" sbt.imports="_root_.sbt.plugins.IvyPlugin, _root_.sbt.plugins.JvmPlugin, _root_.sbt.plugins.CorePlugin, _root_.sbt.plugins.JUnitXmlReportPlugin, _root_.sbt.plugins.Giter8TemplatePlugin, sbt._, Keys._, dsl._" sbt.resolvers="https://repo1.maven.org/maven2/|maven|public, C:\Users\jll\.ivy2\cache|ivy|Local cache" type="SBT_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="false">
<module external.linked.project.id="courses-build" external.linked.project.path="$MODULE_DIR$/../../project" external.root.project.path="$MODULE_DIR$/../.." external.system.id="SBT" sbt.imports="_root_.sbt.plugins.IvyPlugin, _root_.sbt.plugins.JvmPlugin, _root_.sbt.plugins.CorePlugin, _root_.sbt.plugins.JUnitXmlReportPlugin, _root_.sbt.plugins.Giter8TemplatePlugin, sbt._, Keys._, dsl._" sbt.resolvers="https://repo1.maven.org/maven2/|maven|public, C:\Users\jleng\.ivy2\cache|ivy|Local cache" type="SBT_MODULE" version="4">
<component name="NewModuleRootManager">
<output url="file://$MODULE_DIR$/../../project/target/idea-classes" />
<output-test url="file://$MODULE_DIR$/../../project/target/idea-test-classes" />
<exclude-output />

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id="courses" external.linked.project.path="$MODULE_DIR$/../.." external.root.project.path="$MODULE_DIR$/../.." external.system.id="SBT" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8" inherit-compiler-output="false">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/../../target/scala-2.11/classes" />
<output-test url="file://$MODULE_DIR$/../../target/scala-2.11/test-classes" />
<exclude-output />

View File

@@ -0,0 +1,10 @@
def mapFun[T, U](xs: List[T], f: T => U): List[U] =
(xs foldRight List[U]())( (a, b) => f(a) :: b )
def lengthFun[T](xs: List[T]): Int =
(xs foldRight 0)( (a, b) => b + 1)
lengthFun(List(3, 4, 5, 6))
mapFun(List(3, 4, 5, 6), (x => 1)) // Couldn't find how to try it out