Growth - Yet another Obfuscated MATLAB code

バージョン 1.5.0.0 (3.87 KB) 作成者: Hikaru Ikuta
Obfuscated MATLAB code where the source looks like its output, with a functional programming demo.
ダウンロード: 561
更新 2015/8/17

編集メモ: This file was selected as MATLAB Central Pick of the Week

This is an obfuscated piece of MATLAB code, where the source text is made to look like its output figure.
This program also demonstrates several techniques for functional programming in MATLAB using anonymous functions. This code runs only by executing a single anonymous function, without touching the global workspace at all, and also without the help of external libraries.
When executed, this code outputs a figure of a forest, consisting of 9 trees. The number of trees to draw could be changed by changing the constant 9 in the end of the code.
In this code, the following features are implemented/used:

- recursion (and loops)
- conditionals (and lazy evaluation)
- local variables ('let' clause)
- execution of multiple statements

Technical details

- Recursion is implemented by using the Y combinator.
- Loops are implemented by tail recursion.
- Conditionals are implemented by evaluating a function chosen from a list,
where the index number is given by a formula consisting of relational operators.
- Lazy evaluation is performed by wrapping an expression with @()
and then applying feval at a desired timing.
- Local variables are implemented by passing constants to a function through its arguments.

Functional Programming in MATLAB is also introduced in:
Introduction to Functional Programming with Anonymous Functions, Part 1
http://blogs.mathworks.com/loren/2013/01/10/introduction-to-functional-programming-with-anonymous-functions-part-1/

引用

Hikaru Ikuta (2024). Growth - Yet another Obfuscated MATLAB code (https://github.com/woodrush/growth), GitHub. 取得済み .

MATLAB リリースの互換性
作成: R2013b
すべてのリリースと互換性あり
プラットフォームの互換性
Windows macOS Linux
カテゴリ
Help Center および MATLAB AnswersFractals についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

GitHub の既定のブランチを使用するバージョンはダウンロードできません

バージョン 公開済み リリース ノート
1.5.0.0

Updated description

1.3.0.0

12.3.2014 - updated screenshot

1.2.0.0

12.3.2014 - updated screenshot

1.1.0.0

12.3.2014 - updated screenshot

1.0.0.0

この GitHub アドオンでの問題を表示または報告するには、GitHub リポジトリにアクセスしてください。
この GitHub アドオンでの問題を表示または報告するには、GitHub リポジトリにアクセスしてください。