Dear Gitlab users, as announced previously (and here), we will be downgrading this Gitlab instance delayed to the Community edition on Thursday, 25.08.22, at 5 pm. You may ignore the (upcoming) banner below displayed by Gitlab.
"get the following information from `alphabet`:\n",
"\n",
"- length\n",
"- first 3 characters\n",
"- the 12th character\n",
"- the 7-10th character\n",
"- the last 5 characters\n",
"\n",
"and then create an `aLPHABET` with upper case characters and add it to the existing one\n"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## problem 2\n",
"implement a function `hasVowel` which checks if a string contains a vowel character. Test the function with \"foo\", \"bar\" and \"bz\".\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## problem 3\n",
"\n",
"use list comprehensions for creating the following sets in haskell\n",
"\n",
"\n",
"- $A = \\{ x \\,:\\, x \\in \\mathbb{N},\\, x \\text{ odd}\\}$ (only showing the first 5 elements)\n",
"- $B = \\{ -x \\,:\\, x \\in \\mathbb{N},\\, 3|x ,\\, x < 10\\}$ ($3|x$ : 3 is a divisor of x)\n"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## problem 4 \n",
"\n",
"Create the set of all odd numbers smaller than 500, which are dividable through 5 and 7.\n",
"\n",
"$S=\\{x : x \\neq 0 \\land 5|x \\land 7|x\\}$\n"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# problem 5\n",
"\n",
"Let $A=\\{1,2,3\\}$, $B=\\{3,4,5\\}$. Calculate the intersection and the union of $A$ and $B$."
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## problem 6\n",
"\n",
"Let `less` and `greater` be functions which have a value `v` and a list of values `l` of the same type as `v`. Return a list of all values which are less or greater as `v`.\n",
"\n",
"$\\text{less}(v,l) = \\{x : x \\in l, x < v\\}$\n",
"\n",
"Implement the functions using list comprehensions.\n",
"\n",
"Test: `5 [1..10]`\n"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## problem 7\n",
"\n",
"the list generated with `[0.1,0.3..0.9]` has problems with precision (has roundingerror). Do it better via using list comprehensions. (Tip: ranges of integral types do not have rounding errors).\n"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Haskell",
"language": "haskell",
"name": "haskell"
},
"language_info": {
"codemirror_mode": "ihaskell",
"file_extension": ".hs",
"name": "haskell",
"version": "7.10.3"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
\ No newline at end of file
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Exercises 03\n",
"\n",
"## problem 1\n",
"\n",
"```haskell\n",
" alphabet = ['a'..'z']\n",
"```\n",
"\n",
"get the following information from `alphabet`:\n",
"\n",
"- length\n",
"- first 3 characters\n",
"- the 12th character\n",
"- the 7-10th character\n",
"- the last 5 characters\n",
"\n",
"and then create an `aLPHABET` with upper case characters and add it to the existing one\n"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## problem 2\n",
"implement a function `hasVowel` which checks if a string contains a vowel character. Test the function with \"foo\", \"bar\" and \"bz\".\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## problem 3\n",
"\n",
"use list comprehensions for creating the following sets in haskell\n",
"\n",
"\n",
"- $A = \\{ x \\,:\\, x \\in \\mathbb{N},\\, x \\text{ odd}\\}$ (only showing the first 5 elements)\n",
"- $B = \\{ -x \\,:\\, x \\in \\mathbb{N},\\, 3|x ,\\, x < 10\\}$ ($3|x$ : 3 is a divisor of x)\n"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## problem 4 \n",
"\n",
"Create the set of all odd numbers smaller than 500, which are dividable through 5 and 7.\n",
"\n",
"$S=\\{x : x \\neq 0 \\land 5|x \\land 7|x\\}$\n"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# problem 5\n",
"\n",
"Let $A=\\{1,2,3\\}$, $B=\\{3,4,5\\}$. Calculate the intersection and the union of $A$ and $B$."