13,737,531 members

Stats

43.8K views
99 downloads
21 bookmarked
Posted 27 Sep 2012
Licenced MIT

ObjectScript: A new programming language

, 9 Oct 2012
The ObjectScript is a new programing language that mixes benefits of JavaScript, Lua, and PHP. The ObjectScript has syntax from JavaScript, multiple results from Lua, OOP from PHP and much more.
 ``` \$maxflips){ \$maxflips = \$flips; } // New maximum? break; } \$q[\$q1] = \$q1; if(\$q1 >= 4){ \$i = 2; \$j = \$q1 - 1; for(;;){ \$tmp = \$q[\$i]; \$q[\$i] = \$q[\$j]; \$q[\$j] = \$tmp; if(++\$i >= --\$j) break; } } \$q1 = \$qq; \$flips++; } } // Permute. if(\$sign == 1){ \$tmp = \$p[2]; \$p[2] = \$p[1]; \$p[1] = \$tmp; \$sign = -1; // Rotate 1<-2. }else{ \$tmp = \$p[2]; \$p[2] = \$p[3]; \$p[3] = \$tmp; \$sign = 1; // Rotate 1<-2 and 1<-2<-3. for(\$i = 3;; \$i++){ \$sx = \$s[\$i]; if(\$sx != 1){ \$s[\$i] = \$sx-1; break; } if(\$i == \$n) return array(\$sum, \$maxflips); // Out of permutations. \$s[\$i] = \$i; // Rotate 1<-...<-i+1. \$t = \$p[1]; for(\$j = 1; \$j <= \$i; \$j++){ \$p[\$j] = \$p[\$j+1]; } \$p[\$i+1] = \$t; } } } } function getTimeSec(){ list(\$usec, \$sec) = explode(" ",microtime()); return (\$usec + \$sec); } \$n = isset(\$argv[1]) ? \$argv[1] : 5; echo "n: \$n\n"; \$start_time = getTimeSec(); \$r = fannkuch(\$n); \$sum = \$r[0]; \$flips = \$r[1]; echo("\$sum\nPfannkuchen(\$n) = \$flips\n" . "time = ".(getTimeSec() - \$start_time)."\n"); ```

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The MIT License

About the Author

 United States
No Biography provided

You may also be interested in...

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web01-2016 | 2.8.180920.1 | Last Updated 9 Oct 2012
Article Copyright 2012 by unitpoint
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid