learn go memoization
package main // 参考文章:
// https://github.com/Unknwon/the-way-to-go_ZH_CN/blob/master/eBook/06.12.md import (
"fmt"
"time"
) const LIM = var fibs [LIM]uint64 func main() {
var result uint64 =
start := time.Now()
for i := ; i < LIM; i++ {
result = fibonacci(i)
fmt.Printf("fibonacci(%d) is: %d\n", i, result)
} end := time.Now()
delta := end.Sub(start)
fmt.Printf("longCalculation took this amount of time:%s\n", delta)
} func fibonacci(n int) (res uint64) {
// memoization: check if fibonacci(n) is already known in array
if fibs[n] != {
res = fibs[n]
return
}
if n <= {
res =
} else {
res = fibonacci(n - ) + fibonacci(n - )
} fibs[n] = res
return
}
learn go memoization的更多相关文章
- Atitit learn by need 需要的时候学与预先学习知识图谱路线图
Atitit learn by need 需要的时候学与预先学习知识图谱路线图 1. 体系化是什么 架构 知识图谱路线图思维导图的重要性11.1. 体系就是架构21.2. 只见树木不见森林21.3. ...
- Python 爬取所有51VOA网站的Learn a words文本及mp3音频
Python 爬取所有51VOA网站的Learn a words文本及mp3音频 #!/usr/bin/env python # -*- coding: utf-8 -*- #Python 爬取所有5 ...
- [转载]VIM 教程:Learn Vim Progressively
文章来源:http://yannesposito.com/Scratch/en/blog/Learn-Vim-Progressively/ Learn Vim Progressively TL ...
- some tips learn from work experience
1.you can't avoid office politics 2.you'll never have a job which you "can't quit" - if yo ...
- Java-集合(没做出来)第四题 (List)写一个函数reverseList,该函数能够接受一个List,然后把该List 倒序排列。 例如: List list = new ArrayList(); list.add(“Hello”); list.add(“World”); list.add(“Learn”); //此时list 为Hello World Learn reverseL
没做出来 第四题 (List)写一个函数reverseList,该函数能够接受一个List,然后把该List 倒序排列. 例如: List list = new ArrayList(); list.a ...
- Learn RxJava
Learn RxJava http://reactivex.io/documentation/operators.html https://github.com/ReactiveX/RxJava/wi ...
- ANSI Common Lisp Learn
It has been a long time that I haven't dealt with my blog. On one hand I was preparing the exams.On ...
- [Notes] Learn Python2.7 From Python Tutorial
I have planed to learn Python for many times. I have started to learn Python for many times . Howeve ...
- 十分钟入门less(翻译自:Learn lESS in 10 Minutes(or less))
十分钟入门less(翻译自:Learn lESS in 10 Minutes(or less)) 注:本文为翻译文章,因翻译水平有限,难免有缺漏不足之处,可查看原文. 我们知道写css代码是非常枯燥的 ...
随机推荐
- filebeat 乱码
查看 文件的类型 [root@elk-node-1 rsyslog] # file 192.168.1.16.log 192.168.1.16.log: Non-ISO extended-ASCII ...
- LeetCode——Palindromic Substrings
Question Given a string, your task is to count how many palindromic substrings in this string. The s ...
- 在Linux Centos 7.2 上安装指定版本Docker。
相关资料链接: https://docs.docker.com/install/linux/docker-ce/centos/#install-docker-ce 先清空下“历史” yum remov ...
- Vjudge - E - 这是高中数学向量题
2017-07-15 22:29:06 writer:pprp 评价,用到了叉乘,很麻烦,C++构造知识必须扎实 题目如下: 我们用逆时针方向的顶点序列来表示,我们很想了解这块地的基本情况,现在请你编 ...
- idea 快捷键及使用技巧
IDEA中经常使用的快捷键: Ctrl+Shift + Enter 语句完成 可以快速在行末添加分号,或添加大括号{} Ctrl+Shift + F 全文查找 需要把搜狗打字的快捷键关掉 Ctrl+A ...
- Fedora安装opengl
Fedora和Ubuntu下安装OpenGL开发环境配置(我整理的)OpenGL开发库的详细介绍fedora23 安装OpenGL 开发OpenGL工程需要3个库文件和对应的头文件:libglut.s ...
- PIL中文文档
(0)http://hereson.iteye.com/blog/2224334 (1)http://blog.csdn.net/yjwx0018/article/details/52852067 ( ...
- JavaScript深拷贝—我遇到的应用场景
简述 深拷贝即拷贝实例,其作用是为了不影响拷贝后的数组对起原数组造成影响.这时我们就需要进行深拷贝.(JavaScript的继承) 我遇到的应用场景 我是在用vue的element-ui做项目的时候遇 ...
- poj1113凸包
就是求凸包的周长加以l为半径的圆周长,证明略 由于之前写过叉积,所以graham扫描算法不是很难理解 #include<map> #include<set> #include& ...
- 转:MyEclipse安装Eclipse Memory Analyzer插件,并进行错误文件分析流程
转自 http://www.cnblogs.com/nb44c/p/5218880.html 1.先安装MAT插件 Memory Analyzer 插件下载地址:http://www.eclipse. ...