Seven More Languages in Seven Weeks (读书笔记):Julia

Julia

  1. Day 1
    1. julia> typeof(5)
    2. ~0 位取反
    3. 5 $ 6 //=> 3
    4. implicit = {:a => 1, :b => 2, :c => 3}
    5. explicit = [:a => 1, :b => 2, :c => 3] //静态类型限定?
    6. Float64[1, 2, 3] //有点Go语言语法的味道?
    7. 切片:animals[2:end]
    8. 多维数组:A = [1 2 3; 4 5 6; 7 8 9] //Matlab?
    9. v .* [0.5; 1.2; 0.1] //点乘
    10. v' * v //内积
  2. Day 2
    1. for a = [1, 2, 3] println("$a") end //这个字符串求值借用的Perl语法?
    2. abstract Story
    3. type Book <: Story ... end //没有指定成员的类型?
    4. super(Book)
    5. subtypes(Story)
    6. numbers = 1:10
    7. +(numbers...)
    8. In Julia, each version of a function is called a method, 但‘不属于特定的类型’?==> Multiple dispatch
    9. 并发:
      1. addprocs(2)
      2. r1 = remotecall(2, rand, 10000000) //嗯?可以直接发起远程调用?
      3. rand_list = fetch(r1) //阻塞等待结果返回(感觉这里的语法有点太原始的,不过适合于数值计算的使用场景)
    10. @parallel (+) for i = 1:times ... end //循环并行化?
    11. Interview with Julia’s Founders: Jeff Bezanson, Stefan Karpinski, Viral Shah, Alan Edelman
      1. Julia注重性能(CPU计算速度、内存布局)?
  3. Day 3
    1. e = :(println("Hello!"))
    2. typeof(e) //=> Expr
    3. (e.head, e.args) //=> (:call,{:println,"Hello!"}) 又是Lisp风格的代码结构表示?
    4. macro unless(t, b) quote ... end end //注意,Julia代码不需要写‘return’
    5. julia> Pkg.add("Images") //靠,在线的包管理,这个牛
      1. 感觉Julia可以直接当作命令行的Matlab来用了?正如R语言对于S
    6. http://media.pragprog.com/titles/7lang/code/julia/Codec.jl (代码略)
      1. julia> using Codec
      2. julia> freqs = Codec.blockdct6(img)
      3. img2 = Codec.blockidct(freqs)
  4. Weaknesses
    1. The first is its youth, and the second is the lack of available packages(这个,-_-)
  5. As Graydon Hoare, creator of the Rust language, puts it, Julia is a “Goldilocks language.” It’s just right.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值