为什么80%的码农都做不了架构师?>>>   

##55

(= (__ [1 1 2 3 2 1 1]) {1 4, 2 2, 3 1})
(= (__ [:b :a :b :a :b]) {:a 2, :b 3})#(into {} (map (fn [[akey aval]] [akey (count aval)]) (group-by identity %)))
;;others
(defn map-frequencies"Map occurrences of numbers.Should not use frequencies function."[xs](reduce (fn [m i] (assoc m i (inc (m i 0)))) {} xs))

##56

(= (__ [1 2 1 3 1 2 4]) [1 2 3 4])
(= (__ [:a :a :b :b :c :c]) [:a :b :c])
#(reduce (fn [xs item](if (some (partial = item) xs)xs (conj xs item))) [] %)

##58

(= "HELLO" ((__ #(.toUpperCase %) #(apply str %) take) 5 "hello world"))
(= [3 2 1] ((__ rest reverse) [1 2 3 4]))
#(fn [& xs] (loop [[fnitem & fns] (reverse %&)rs xs](if fnitem (recur fns (list (apply fnitem rs)))(first rs))))
;;other
#(fn [& args](first (reduce (fn [args fnitem](list (apply fnitem args)))args (reverse %&))))

##59 Take a set of functions and return a new function that takes a variable number of arguments and returns a sequence containing the result of applying each function left-to-right to the argument list

(= ["HELLO" 5] ((__ #(.toUpperCase %) count) "hello"))
(= [2 6 4] ((__ :a :c :b) {:a 2, :b 4, :c 6, :d 8 :e 10}))(fn ([] [])([a b] (fn [& args] [(apply a args) (apply b args)]))([a b c] (fn [& args] [(apply a args) (apply b args) (apply c args)])))
;;or
(fn [& fns] #(map (fn [fnitem](apply fnitem %&)) fns))

##60 reductions

;;Write a function which behaves like reduce, but returns each intermediate value of the reduction. Your function must accept either two or three arguments, and the return sequence must be lazy.
(= (take 5 (__ + (range))) [0 1 3 6 10])
(= (__ conj [1] [2 3 4]) [[1] [1 2] [1 2 3] [1 2 3 4]])(defn my-reductions([f xs](my-reductions f (first xs) (rest xs)))([f init xs](cons init (lazy-seq(when-not (empty? xs)(my-reductionsf(apply f (list init (first xs)))(rest xs)))))))

##66最大公约数

(fn greatest-common-divisor [a b](loop [gcd (min a b)](if (= 0 (rem a gcd) (rem b gcd))gcd(recur (dec gcd)))))

##61 zipmap

(= (__ [:a :b :c] [1 2 3]) {:a 1, :b 2, :c 3})(fn [xs1 xs2](into {}(map#(identity [% %2])xs1 xs2)))
;;其它实现
(fn [xs1 xs2](apply hash-map(interleavexs1 xs2)))

##62 implement iterater

(fn my-iterate [f init](lazy-seq(cons init (my-iterate f (f init)))))

##63 implement group-by

(fn [f col](reduce(fn [m x](assocm(f x)(conj (m (f x) []) x))){}col))

转载于:https://my.oschina.net/diqye/blog/523116

#55 #56 #58 #59 #60 #66相关推荐

  1. 宏碁暗影骑士AN515-55/57/58原厂预装系统oem镜像

    宏碁暗影骑士AN515-55/57/58原厂预装系统oem镜像 文件分享地址https://pan.baidu.com/s/1snKOsH3OMl3GZLqeAf-GLA?pwd=8888 1.安装完 ...

  2. BUPT-CSAPP 2019 Fall 3.58 3.60 3.63

    深入理解计算机系统 写在前面: 1.这是我的个人作业,在这里写什么样我交上去就是什么样,希望各位不要原样抄袭. 2.这里的题目只是我OCR了方便搜索,真要看题目还是得书. 3.CSDN的Markdow ...

  3. DT大数据梦工厂 第55,56讲

    王家林亲授<DT大数据梦工厂>大数据实战视频"Scala深入浅出实战经典"视频.音频和PPT下载!第55讲:Scala中Infix Type实战详解 百度云盘:http ...

  4. 国庆第七日(2014年10月7日17:55:56),随手记,一些关注的OSC软件,花生壳

    (1)最难过的是今天. (2)随手记:001.002. (3)htmlunit.joda-time.date4j.jdao.BeanGenerator.JavaScript秘密花园(开源图书)  OS ...

  5. 第55~56讲-find 方法与findNext方法

    1 ·单元格区域的find方法: Find方法在区域内查找某值的第一个单元格,注意返回找到的单元格对象 Find方法只且永远返回该区域第一个匹配的对象 ·查找下一个需要使用FindNext或者Find ...

  6. 基因驱动 CovEx 代码阅读(一)

    CovEx 源代码 https://sourceforge.net/projects/cancer-pathway/ 首先重点阅读 README1.txt 一步一步执行 安装 Gurobi Optim ...

  7. 网络算法(图算法)-营救问题(python实现)

    营救 题目大意: 你是红军指挥官,在一场军事演习中,你的部分军队被蓝军包围了.蓝军包围的方式如下 在上图中,每个顶点表示蓝军的部队,顶点中数字表示蓝军在此处的人数(千人),两点间的边表示蓝军两个部队间 ...

  8. (转载)混合图层算法

    1正常模式:混合色*不透明度+(100%-混合色不透明度) 2溶解模式:溶解模式下混合色的不透明度及填充都是100%的话,我们就看不到基色图层.降低混合色图层的不透明度后,我们就会发现结果色中出现了很 ...

  9. python用xlwings从一个表格复制到另一个表格里,xls文件的某一解决方式。

    直接去最底部复制代码,每一行都有备注,能够看懂,中间是我在做的过程中踩到的坑. 我用python已经修改好了上传饿了么的表格,但是美团是xls格式,openpyxl好像是不能修改的 那么只有换个其他的 ...

最新文章

  1. 一直想测试的NGINX变量输出,最于有办法了。
  2. Android中activity传值的两种方式
  3. canvas象棋 画图
  4. 位地址和字节地址换算_关于ip地址的详解,看完这篇就够了
  5. 为了简单起见,Arquillian Chameleon
  6. C语言编程规范--代码注释
  7. 10 本大数据高分书籍,收好给头脑充充电吧~
  8. 做游戏,学编程(C语言) 6 数组之空战游戏
  9. [GDAL]3.影像金字塔构建
  10. idea中通过搜索添加maven依赖包
  11. Server(Iocp)的那些烦恼
  12. php speex,将微信jssdk录制的speex高清音频转换为wav/mp3
  13. python开发语音录入_用Excel及Python实现数据录入语音校对功能
  14. 华为nova2s应用计算机,华为nova2s 如何打开多个应用 | 手游网游页游攻略大全
  15. 【GBT28181开发:SIP协议实践】之设备状态查询
  16. 2016第二届美亚杯电子数据取证(个人赛)
  17. 操作系统虚拟存储管理实验
  18. 高压开关柜无线测温系统(高压开关柜在线监测系统应用案例)
  19. Android 六大布局
  20. 海外时事热点|两轮车租赁模式再度升级

热门文章

  1. 澳政府投资光伏发电 内外资项目角逐高额补助
  2. 【沫沫金】安卓手机版 - 日期控件
  3. Exchange Server 2016 之三:邮箱角色部署
  4. Verilog作业(一)
  5. squid代理简单应用
  6. cocos2dx视频教程进阶篇--第1天--吃西瓜游戏。
  7. 有关ArrayList增加Map引发的一个BUG
  8. apt-get安装与卸载
  9. JavaScript权威指南笔记 - 1
  10. 如何更优雅地切换Git分支