找回密码
 立即注册
查看: 2025|回复: 0

R语言问题求助

[复制链接]
发表于 2015-3-6 20:04:59 | 显示全部楼层 |阅读模式
本帖最后由 rainviewer 于 2015-3-6 20:07 编辑

open.account=function(total){
     list(
     deposit=function(amount,total){
     if(amount==0)
     stop('Deposits must be positive!\n')
     total=total+amount
     cat(amount,"deposited. Your balance is",total,"\n\n")
     },
     withdraw=function(amount,total){
     if(amount>total)
     stop("You don't have that much money!\n")
     total=total-amount
     cat(amount,"withdraw. Your balance is",total,"\n\n")

     },
     balance=function(total){
     total=total
     cat("Your balance is",total,"\n\n")
     total}
       )
    }
跪求分析:当运行这段代码时,total参数是怎么传递的?假设如下调用
total=100
ross=open.account(total)
ross$withdraw(30)
ross$balance()##怎么使得这条命令成功运行?


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|R语言中文网

GMT+8, 2024-11-25 20:31 , Processed in 0.026636 second(s), 17 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表