35、Julia开发工具与性能优化全解析

Julia开发工具与性能优化全解析

1. 文档字符串与函数定义

在Julia中,文档字符串是紧跟在函数定义前的字符串,用于提供函数的帮助信息。例如,在 panto.jl 文件中,定义了三个与哑剧角色相关的函数: aladdin genie alibaba

"""
Calculate the sum of the series i/(i+1)^2 using the genie function for 
an integer i in the range [1:n].
"""
function aladdin(n::Integer)
    @assert n > 0
    s = 0.0
    for i in 1:n
        s += genie(i,2)
    end
    return s
end

"""
Compute the value of the expression x/(x+1)^k where x is a numeric and 
k is a (non-complex) number.
"""
genie(x,k) = x/(x+1)^k

const N_THIEVES = 40; 

"""
Compute and store the items using Aladdin's genie storing each partial 
sum of the series i/(i+1)^2 in an array upto a value of 40.
So 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值