Skip to content
This repository was archived by the owner on Jan 21, 2019. It is now read-only.
This repository was archived by the owner on Jan 21, 2019. It is now read-only.

原型探讨: 基于自然语言的编程语言 #1

@nobodxbodon

Description

@nobodxbodon

program-in-chinese/overview#16 的后续

这里是起初的设想. 先写点假想的例程看看, 如果有可行性的话,就试着做个原型.

下面这段话(出处):

某投资方法,可以有8%的年回报率,那么1000元的初始投入资金,3年之后会变成多少

结巴分词之后是:

某 / 投资 / 方法 / , / 可以 / 有 / 8 / % / 的 / 年 / 回报率 / , / 那么 / 1000 / 元 / 的 / 初始 / 投入 / 资金 / , / 3 / 年 / 之后 / 会 / 变成 / 多少

然后, 关键的问题是如何从这里到下面的代码逻辑(暂用Java演示, 其他语言或者伪代码亦可):

    float 资金 = 1000f;
    float 年回报率 = 0.08f;
    for (int 年份 = 0; 年份 < 年限; 年份 ++) {
      资金 = (1 + 年回报率) * 资金;
    }
    return 资金;

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions