83 lines
1.7 KiB
Text
83 lines
1.7 KiB
Text
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 13,
|
|
"id": "0f99fcb7-762f-447c-833d-f0e61b01cd3c",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"fibs = 0 : 1 : zipWith (+) fibs (tail fibs)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "21cd7022-93ad-44e4-af07-695f2831ca47",
|
|
"metadata": {},
|
|
"source": [
|
|
"it looks like the following"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "raw",
|
|
"id": "202121f5-b7d3-4a23-b29b-d0ad679cc5d2",
|
|
"metadata": {},
|
|
"source": [
|
|
"0,1,1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597,2584,4181,6765"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "e49c7c8c-8f40-4429-91c7-6f8ffd6ec261",
|
|
"metadata": {},
|
|
"source": [
|
|
"get first item of each iteration and then drop 3 items from the beginning"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "raw",
|
|
"id": "b92a154b-99ad-4558-aeb1-635a4ad04570",
|
|
"metadata": {},
|
|
"source": [
|
|
"0,2,8,34,144,610,2584"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 14,
|
|
"id": "9265e55e-64e6-4aff-a541-5896a032f66b",
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"4613732"
|
|
]
|
|
},
|
|
"metadata": {},
|
|
"output_type": "display_data"
|
|
}
|
|
],
|
|
"source": [
|
|
"sum . takeWhile (<= 4000000) . map head . iterate (drop 3) $ fibs"
|
|
]
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": "Haskell - haskell",
|
|
"language": "haskell",
|
|
"name": "ihaskell_haskell"
|
|
},
|
|
"language_info": {
|
|
"codemirror_mode": "ihaskell",
|
|
"file_extension": ".hs",
|
|
"mimetype": "text/x-haskell",
|
|
"name": "haskell",
|
|
"pygments_lexer": "Haskell",
|
|
"version": "9.0.2"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 5
|
|
}
|