Source code and markup for the site http://hyperpolyglot.org.
clarkgrubb / hyperpolyglot Goto Github PK
View Code? Open in Web Editor NEWhyperpolyglot.org
License: Other
hyperpolyglot.org
License: Other
Source code and markup for the site http://hyperpolyglot.org.
It would be nice to include exit message syntax for languages.
PHP
die("Message goes here");
Ruby
abort("Message goes here")
Python
import sys
sys.exit()
Javascript
// In browser
// none
// In node.js
console.log("Message goes here");
process.exit();
Hi, there are some missing examples for reStructuredText
Internal crossreferences, like foo_.
.. _foo:
This is an example foo target.
.. _foo:
text
.. role:: foo
An example of using :foo:`interpreted text`
+-------+
| title |
+===+===+
| 1 | 2 |
+---+---+
.. code-block:: c
int add(int a, int b) {
return (a+b);
}
pygmentize -L lexers
http://hyperpolyglot.org/unix-shells
cmd1 && cmd2
(fish-shell = cmd1; and cmd2
)cmd1 || cmd2
(fish-shell = cmd1; or cmd2
)cmd1; [or|and] cmd2
I was quit surprised to determine the sites "own" language isn't on the the list of lightweight markup languages.
Quick Reference http://www.wikidot.com/doc:quick-reference
Live view if you create account.
Essentially, running "screen -ls" should get you the list of running sessions. Would be good to add that in.
The statement that Java's local variables are zero when uninitialized is not correct, a compile time error occurs instead:
If a declarator does not have an initializer, then every reference to the variable must be preceded by execution of an assignment to the variable, or a compile-time error occurs by the rules of §16 (Definite Assignment).
From JLS 14.4.2
Minor issue. You have to use flet or labels in CL to define a local function.
(flet ((double (x) (* 2 x))) (double 2))
In addition I would include intern
and string
for converting between symbol names and strings.
http://stackoverflow.com/questions/32670266/lisp-anonymous-function-local-variable
I'm not certain if unless
and when
(some more lisp macros) should have been included.
Can you create another entry in the first table "Grammar" for fish, row "simple command with environment variable"? env EDITOR=vi git commit
is indeed correct, but there is another way that will work with fish functions as well, whereas env
expects a real command. The other option is:
begin; set -lx EDITOR vi; git commit; end
This is actually the equivalent in fish using fish grammar and syntax. The env command method works for all shells.
See fish-shell/fish-shell#2415 for a discussion.
There are a few omissions from Clojure. Also there are several uses of Java interop to get effect that are built into the standard Clojure system. Included are suggested improvements.
Identifier characters can contain non-alphnumeric unicode (though for a standard keyboard the description is correct).
If binary predicates can be considered, then "type predicates" should include "instance?"
Relational operators should read "= not= < > <= >="
Rational decomposition should be "numerator denominator"
Random number should be (rand) (rand 100), (rand-int 100)
Character access can be (nth "foo" 0)
Extract substring: (subs "foo bar" 4 7) and (subs "foo bar" 4)
Length can be: (count "foo")
Constructors: (apply str (repeat 3 \f)) (apply str '(\f \o \o))
Comparison: (= "foo" "bar") (compare "foo" "bar")
Case: (clojure.string/lower-case "FOO")
Trim: (clojure.string/trim " foo ")
Split: (split "foo bar baz" #"[ \t\n]+")
Join: (apply str '("foo" "bar" "baz"))
Format: (format "%s: %d %.2f" "Foo" 7 13.457)
Regex substitution: (clojure.string/replace "hello" #"[^l]l" "XX") (clojure.string/replace-all "hello hello" #"[^l]l" "XX"
Current date/time: (java.util.Date.)
Sequence predicate: (seq? '(1 2 3)) (sequential? '(1 2 3)) (sequential? [1 2 3]) (vector? [1 2 3])
Iterate over hash entries: (doseq [[k v] h](println k) (println v)). Alternatively, use "key" and "val" instead of "first" and "second"
Map hash to list: (def hkeys (keys h)) (def hvals (vals h))
Defstruct: (deftype account [id balance])
Struct: (def a (->acc 3 17.12))
Struct setter: (assoc a :balance 0)
Struct predicate: (record? a)
Variable number of arguments: (defn add [a & b](if %28nil? b%29 a %28apply + a b%29))
Named parameter: (defn logarithm [&{x :number b :base}](/ %28Math/log x%29 %28Math/log b%29))
(logarithm :base 2 :number 8)
Return multiple values is always done with a vector: (defn sqrts [x] [(Math/sqrt x) (- (Math/sqrt x)])
Create thread: (future (println "running..."))
Wait on a thread: (def t (future (Thread/sleep (* 30 1000))))
(deref t)
Read line from stdin: (def line (read-line))
Open file for reading: (def in (clojure.java.io/reader "/etc/hosts"))
Open file for writing: (def out (clojure.java.io/writer "/tmp/test"))
Open file for appending: (def out (clojure.java.io/writer "/tmp/test" :append true))
Close file implicitly: (with-open [out (clojure.java.io/writer "/tmp/test")](.write out))
Read file into array of strings: (clojure.string/split-lines (slurp "/etc/hosts"))
Read file into string: (slurp "/etc/hosts")
Write string: (spit "/tmp/test" "lorem ipsum")
Write line: (do (.write out "lorem ipsum") (.newLine out))
Flush file handle: (.flush out)
File test, regular file test: (.exists (clojure.java.io/file "/tmp/foo")) (.isFile (clojure.java.io/file "/tmp/foo"))
File size: (.length (clojure.java.io/file "/tmp/foo"))
Is file readable, writable, executable: (def f (clojure.java.io/file "/tmp/foo"))
(.canRead f) (.canWrite f) (.canExecute f)
Set file permissions: (def f (clojure.java.io/file "/tmp/foo"))
(.setReadable f true) (.setWritable f true) (.setExecutable f true)
Copy file, remove file, rename file: (clojure.java.io/copy "/tmp/foo" "/tmp/bar")
(clojure.java.io/delete (clojure.java.io/file "/tmp/foo"))
(.renameTo (clojure.java.io/file "/tmp/foo") (clojure.java.io/file "/tmp/bar"))
Create temp file: (java.io.File/createTempFile "foo" ".tmp")
There is some inconsistency between accepting new values vs. mutation. For instance, "push" suggests that Clojure has no equivalent (it can use conj, but this creates a new sequence), while "set element vector" and "rem-hash" suggest "replace" and "dissoc", which will not change the value of the provided vector.
The first nit.
variable:
/* if inside function, memory allocated on stack: */
int i;
int j = 3;
/* memory allocated on heap: */
int *ptr = malloc(sizeof(int));
*ptr = 7;
It really should check for an out of memory error. Also, it is more
idiomatic to do malloc(sizeof *ptr)
. But these are just nits.
uninitialized variable:
Stack variables and heap variables allocated with malloc have
indeterminate values. Global and static variables and heap variables
allocated with calloc are zero-initialized.
This is incorrect. Reading from uninitialized variables is undefined
behaviour and can result in bad things like the compiler deleting
code. Those variables aren't just indeterminately initialized. Also,
a very tiny nitpick is that calloc
zero initializes bytes but does
not necessarily zero initialize the value. Of course, now a days it
doesn't matter but it used to be the case that some platforms had null
pointer representations that weren't represented by zero bytes.
type size:
type size sizeof(int)
/* also expressions and values: */
sizeof(1 + 1)
A nitpick, sizeof
is an operator and not a function. It does not
require parentheses for expressions.
boolean type:
int
/* includes macros for consistency with C++: */
#include <stdbool.h>
bool
No, stdbool.h
aren't just macros. All standard conforming C99
implementations implement a _Bool
type which is entirely separate
from int
.
integer type:
signed char 1+ byte
short int 2+ bytes
int 2+ bytes
long int 4+ bytes
long long int 4+ bytes
This is platform specific. If you want exact sized types use
stdint.h
which gives you types like uint16_t
.
float type:
float type float 4 bytes
double 8 bytes
long double 16 bytes
This is platform specific and also incorrect. The old way of doing
math on x86 platforms had 80 bit floating point registers instead of
64 bit floating registers so for higher performance instead of
normalizing numbers to 64 bits after every operation the bits were
kept in for extended precision. This leads to enormously confusing
and weird results such that even expressions like a == a
may fail
(or more likely something like, a = b + c, a == b + c`).
random number:
/* Value between 0 and RAND_MAX inclusive: */
int n = rand();
/* Value in interval [0.0, 1.0]: */
float x = (float)rand()/(float)RAND_MAX;
Please don't recommend rand
. Lots of implementations are crappy and
rand
is defined to be seeded with the exact same value at program
start anyways.
string type:
char *
wchar_t *
The size of wchar_t is compiler dependent; gcc and clang use 32 bits;
msvc uses 16 bits.
This is false. This is platform dependent and not compiler dependent
(also many compilers have options to change its size anyways). For
example, may cross compiler to Windows that is based on GCC has
wchar_t
as 16 bits.
longjmp:
void
callee(jmp_buf env) {
longjmp(env, 3);
/* unreachable */
}
void
caller() {
jmp_buf env;
int rv;
if ((rv = setjmp(env)) == 0) {
/* rv is 0 */
callee(env);
/* unreachable */
}
/* rv is 3 */
}
Technically speaking this goes against the POSIX standard.
An application shall ensure that an invocation of setjmp() appears in
one of the following contexts only:The entire controlling expression of a selection or iteration statement One operand of a relational or equality operator with the other operand an integral constant expression, with the resulting expression being the entire controlling expression of a selection or iteration statement The operand of a unary '!' operator with the resulting expression being the entire controlling expression of a selection or iteration The entire expression of an expression statement (possibly cast to void)
If the invocation appears in any other context, the behavior is
undefined.
dirname and basename:
#include <libgen.h>
/* return pointers to statically allocated memory
which is overwritten by subsequent calls */
char *s1 = dirname("/etc/hosts");
char *s2 = basename("/etc/hosts");
This is actually the behaviour of the prestandardised basename
and
dirname
. Under the POSIX standard dirname
and basename
may
modify their arguments which is shitty but what it is.
absolute pathname:
#include <limits.h>
char buf[PATH_MAX];
if (realpath("..", buf) == NULL) {
perror("realpath failed");
}
else {
/* use buf */
}
The situation with realpath
is fucked up. Filesystems are
dynamically loadable in many systems so there usually isn't such a
thing as a constant PATH_MAX
value (many platforms define it but
don't obey it in practise). What you should be able to do is just
realpath(foo, 0)
but that can be buggy on certain versions of Mac OS
X so I don't know a real solution to this.
set signal handler:
#include <signal.h>
void
handle_signal(int signo) {
switch(signo) {
case SIGUSR1:
puts("caught SIGUSR1");
break;
default:
printf("unexpected signal: %s", strsignal(signo));
break;
}
}
/*2nd arg can also be SIG_IGN or SIG_DFL */
sig_t prev_handler = signal(SIGUSR1, &handle_signal);
if (prev_handler == SIG_ERR) {
perror("signal failed");
exit(1);
}
This signal handler is not async-signal safe. It also doesn't
properly handle platforms that clobber the signal handler after it is
used. It also clobbers errno
. On POSIX systems you can save
errno
, use write
and then restore errno
but on other systems
things are fucky.
conditional compilation;
#if defined(__WIN32)
win32_prinft("%f\n", x);
#else
printf("%f\n", x);
#endif
defined
doesn't need parantheses.
i/o errors:
Functions return values such as EOF, NULL, or -1 to indicate error. In
some cases errors are not distinguished from end-of-file. The
functions ferror() and feof() can be used to test a file handle.The type of error is stored in errno. strerror(errno) converts the
errors code to a string and perror() writes its argument to stderr
with sterror(errno).
Please recommend strerror_r
instead of strerror
. Also, functions
sometimes return error codes directly.
struct initialization:
struct medal_count spain = { "Spain", 3, 7, 4};
struct medal_count france = {
.gold = 8,
.silver = 7,
.bronze = 9,
.country = "France"
};
You can also do france = (struct medal_count) { .gold = 8, .silver = 7, .bronze = 9, .country = "France" };
. which the detailed notes for this entry seem to have missed.
It would be useful to have info on AWS, Google Cloud, Heroku, etc!
I would like to contribute to the numerical computation sections. If I read the Makefile correctly, basically it downloads the wikipages from the old hosting domain and extracts html out from it.
Is the (a) wiki to edit these pages still around?
This can be done by
hg init
hg checkout null
Hi! I had a quick search to see if anyone had asked this already but couldn't see anything. Any plans to add perl? Awesome tool!
Ian
Would it be interesting to add Factor to the stack-based languages?
I'd have a go at this myself but I'm not sure how to preview and check the markup syntax.
The line "the debugger has a console pane, which is a JavaScript REPL" is a helpful description for the most part. But it's not entirely accurate. Perhaps it's worth pointing out some of the quirks and differences between the console and JS engines, even if it's just a simple link to @getify's blog post or another site's description.
From https://golang.org/ref/spec#Declarations_and_scope:
The scope of an identifier denoting a constant, type, variable, or function (but not method) declared at top level (outside any function) is the package block.
The only things that are file-scoped are imports.
Capitalization does not affect scope inside the package, it affects whether the identifier is exported (and thus available from outside the package).
Rather than
class sleep10(threading.Thread):
def run(self):
time.sleep(10)
thr = sleep10()
thr.start()
you can just use:
thr = threading.Thread(target=time.sleep, args=(10,))
thr.start()
Uppercase word - gUw
Lowercase word - guw
Indent line - >>
Indent region - visual mode >
Git blame on buffer: Install Git Fugitive, :Gblame
Uppercase and lowercase accept movements, so you could talk about gUU
as "uppercase line"
Is there any plan to add a comparison for Microsoft languages? I see C#, but really there should be a section for comparing:
C#, C#.NET, VB, and VB.NET
I understand that .NET itself is not a language but there are differences in how you program with C# and VB depending upon if you are using .NET, and there are many equivalents between the two languages even without .NET.
This would be very useful for someone like myself that does a lot with one language, but only occasionally does work in the other (and even more rarely, without .NET).
Time permitting, I can contribute some to the knowledge base if there is interest in adding this set of comparisons.
Minor issue. You have to use flet or labels in CL to define a local function.
(flet ((double (x) (* 2 x))) (double 2))
http://stackoverflow.com/questions/32670266/lisp-anonymous-function-local-variable
is currently listed as function -e ll
but should be functions -e ll
.
Hi there,
to get some "fresh air" into you shell comparison article (http://hyperpolyglot.org/unix-shells), you may want to look at "jsh", the "Java Shell" that I wrote:
https://github.com/janino-compiler/jsh
Regards,
Arno
Is wrong, in http://hyperpolyglot.org/json, the affirmation newline in literal: not allowed; use \n escape sequence.
I think it would be great if this document were to distinguish between shell features and external commands, by using a special color or font, for example, for external commands, in the tables.
For example, "simple command with environment variable" in table Grammar. Some of the shells do not support this feature themselves, but the env command can be used for the purpose. But env is an external command, so it doesn't work with shell functions or aliases. So it would be really convenient to see at a glance (e.g. color or font style or whatever) that env is an external command.
var a = [1, 2, 3];
add3.apply(window, a);
I would love to see elixir on this page: http://elixir-lang.org/
Should it rather be next to erlang because they two use the same VirtualMachine, or should it be in another comparision?
The multiplexers page is missing the session name escape (%S) that was added in the screen-4.1.0 release.
cf. https://savannah.gnu.org/bugs/index.php?23738
Threading example:
http://en.cppreference.com/w/cpp/thread/thread/thread
Locks examples:
http://en.cppreference.com/w/cpp/thread/lock_guard
What I see at a glance.
:: is often used as comment (but within brackets can cause problems -> http://ss64.com/nt/rem.html )
multi line comments are possible -> http://stackoverflow.com/questions/8526946/commenting-multiple-lines-in-dos-batch-file . My personal favorite is break||(....) though the closing bracket can be a problem.
Variable identifiers are NOT case sensitive with the exception of FOR /F command tokens -> http://ss64.com/nt/for_f.html
null within batch script %% can be used as empty variable (or !! under delayed expasnsion) . nul is an null device.
null test (can be used also as undefined test):
IF DEFINED VARIABLE_NAME
or
IF "%VARIABLE_NAME%" equ ""
prints "Divide by zero error." and sets errorlevel to 1073750993
has a special dynamic variable %RANDOM% (or !RANDOM! under delayed expansion) which produces a number from 0 to 32767
in case of overflow SET /A prints "Invalid number. Numbers are limited to 32-bits of precision." and sets errorlevel to "1073750992" . In other cases overflow can be tricky -> http://www.dostips.com/forum/viewtopic.php?f=3&t=3758
http://ss64.com/nt/syntax-esc.html
usually special characters are escaped with ^ . percent symbol is escapes with another percent symbol.Under delayed expansion exclamation mark is escaped with double ^^ . After piping is double escaping is needed
You already have length function - is there a reason not to be included in the list
There are implemented such subroutines , but is not built-in
set "s=foo bar"
echo %s:~4,3%
http://ss64.com/nt/syntax-substring.html
set s1=string1
set s2=string2
set conc=%s1%%s2%
/string concatenation and sub-string are shifted in powershell section /
everything is taken as string by SET command (without /A swith)
FINDSTR command has a limited regex match support
set s=hello
echo %s%|findstr /r "[a-z][a-z]*" && (echo match ) || (echo does not match)
http://ss64.com/nt/syntax-replace.html
set "s=do re mi mi mi"
echo %s:mi=ma%
from windows vista and above - timeout -http://ss64.com/nt/timeout.html
for nt/xp/2003 (sleep 30 seconds)
timeout /t 30 /nobreak > NUL
or
w32tm /stripchart /computer:localhost /period:1 /dataonly /samples:30 >nul 2>&1
empty string
return nonzero status
if errorlevel 1 (
echo something bad happened
)
or
if %errorlevel% NEQ 1 (
echo something bad happened
)
continues with the next command
echo something
or
echo something >1
1
2
3
< myfile.txt (
set /p line1=
set /p line2=
set /p line3=
set /p line4=
set /p line5=
)
or
for /f "delims=" %%a in (myfile.txt) do (
echo current line:%%a
)
setlocal enableDelayedExpansion
set "file_content="
for /f "delims=" %%a in (myfile.txt) do (
set "file_content=!file_content! %%a"
)
echo %file_content%
echo "hello" > \tmp\a
echo "hello" >> \tmp\a
%cd% or %__cd__%
%~dp0 (if shift command is not executed)
set "current_dir=%cd%"
I guess (not having a zsh available myself):
${foo:t}}
should be
${foo:t}
As a sidenote: not sure if it's a tongue-in-cheek joke to have the second code line in 'quoting and escaping' to read ispum instead of ipsum?
I am a novive can be added in the README how local generated tutorial
Hi
I note that your computer algebra section is a bit thin - you have nothing on groups and algebra in GAP, or some other interesting subtopics, with which I am familiar. I use GAP, and have used it for several years, for computational group theory, in which I have published papers - I have a GitHub project here for a Django web application I'm developing for publishing a large GAP-derived dataset related to the GAP small groups library. I have also been learning SAGE.
No doubt hyperpolygot is a work in progress, and I don't know what your future plans are - but I think I could also also help with the categorisation of topics and comparisons. For example, I think you could separate computer algebra systems (or algebraic/symbolic computation systems, like GAP, Sage, SymPy, Magma etc., with non-symbolic (numerical and statistical) computational systems like Matlab, NumPy, R etc., as there are fundamental differences obviously.
FYI I have forked this and will be adding to the fork and probably making a pull request soon, maybe as soon as next week.
P. S. The latest version of GAP is 4.7.6.
For a lot of lines batch cell is set to none or is empty (or incomplete) though there are ways the limitations to be worked around with hacks/functions and etc.
And I'm not handy with markdown formatting so I suppose you should also read this as plain text also.
0.version - ver command - will print the version of windows. Also %CMDEXTVERSION% variable prints the version of the command prompt which hasn't been changed since windows 2000
1.getting CPU usage - in batch script use double % :
typeperf "\Processor(_Total)% Processor Time" -sc 1
2.List all variables
set " -> this will list more variables (though is rather a hack)
3.Libraries
there's a hack that allows you to call a function from another batch: http://stackoverflow.com/a/30170342/388389
4.environment variable
environment variables are imported to the cmd and they can be accessed with %variable% -or- with delayed expansion !variable!
5.Getting the username:
whoami
-or-
echo %username%
6.command substitution
doskey ls=dir /b . though doskey macros cannot be used in batch file
7.speech
mshta "javascript:code(close((V=(v=new ActiveXObject('SAPI.SpVoice')).GetVoices()).count&&v.Speak('hyperpolyglot')))"
8.Command path:
for %%a in ("cmd.exe") do @echo %%~f$PATH:a
9.there are lot of ways to start a background process but requires a more complicated function script
10.suspend should be ctrl+c
11.terminate process:
taskkill /im cmd* /f
-or-
tskill cmd
12.list processes
tasklist
-or-
qprocess
16.is readable, is writeable, is executable
attrib command should be used here - http://ss64.com/nt/attrib.html
for %%# in ("somefile") do echo %%~z#
setlocal enableDelayedExpansion
set counter=1
for /f "useback tokens=* delims=" %%# in ("c:\somefile.txt") do (
(echo(line !counter!:%%#)
set counter=counter+1
)
19.write file to stdout
type someFile.txt
despite there's a bug in FOR /L and breaking does not work so good with large numbers - http://www.dostips.com/forum/viewtopic.php?f=3&t=5778
but for other FOR loops will work
for /l %%# in (1;1;10) do (
if %%# equ 5 (
goto :break_for
)
echo %%#
)
:break_for
21.default scope
scope can be limited with ENDLOCAL and SETLOCAL commands - http://ss64.com/nt/setlocal.html
22.Anonymous functions are possible with a hacks...
one of them are the macros - http://ss64.com/nt/syntax-macros.html
the other way is to abuse one bug in CALL function - this one is more close to the anonymous function definition https://github.com/npocmaka/batch.scripts/blob/master/discovers_and_bugs/discovers/anonymous.bat
set string1=zig
set string2=zag
if %string1% equ %string2% echo strings are identical
@echo off
setlocal enableDelyedExpansion
set "string=_"
set "result="
for /l %%# in (1 , 1 , 80 ) do (
set "result=!result!!string!"
)
echo %result%
@echo off
setlocal enableDelayedExpansion
set string="AaBbCC"
for %%# in (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) do set string=!string:%%#=%%#!
echo %string%
to lower
@echo off
setlocal enableDelayedExpansion
set string="AaBbCC"
for %%# in (a b c d e f g h i j k l m n o p q r s t u v w x y z) do set string=!string:%%#=%%#!
echo %string%
.ads -- Spec file
.adb -- Body file [implementation]
.ada -- File containing multiple compilation units or completion of SEPARATE packages/subprograms.
block with local scope:
declare
x : integer; -- local variable
begin
null; -- operations go here.
end;
free memory
call an instantiation of Ada.Unchecked_Deallocation
on the appropriate access type.
conditional expression (in Ada 2012)
(if CONDITION then VALUE_1 else VALUE_2)
(case VARIABLE is
when COND_1 => RESULT_1,
when COND_2|COND_3 => RESULT_2, -- using alternatives
when COND_4..COND_8 => RESULT_3, -- using ranges
when COND_9..COND_11|COND_13 => RESULT_4 -- using both
when others => RESULT_5 -- using default; w/o an others case coverage of all possible values is enforced.
)
integer type
Integer
Float
(user defined)
Type Currency is delta 0.01 digits 20;
(for S being a Scalar subtype)
S'Min( S_1, S_2 )
S'Max( S_1, S_2 )
integer division
3 / 7
square root
Ada.Numerics.Elementary_Functions.Sqrt
absolute value and sign
abs
(Given B as an instantiation of Ada.Strings.Bounded.Generic_Bounded_Length)
B.Bounded_String
Ada.Strings.Unbounded.Unbounded_String
etc.
on this page http://hyperpolyglot.org/pascal
code to get plpgsql/postgresql version is wrong
reason: psql --version
only gives the client version, not the version that will be interpreting the code.
should be this query: SELECT version();
at the psql prompt.
I noticed the re-raise exception section is empty.
In this case, PHP is exatcly like Javascript/Node:
try {
throw new Exception("bam!");
} catch (Exception $e) {
trigger_error("Re-throw", E_USER_WARNING);
throw $e;
}
It's also possible to chain exceptions as of PHP 5.3:
try {
throw new Exception("Bam!");
} catch (Exception $first) {
throw new Exception("Another!", null, $first);
}
In this case, the output would be:
Uncaught exception 'Exception' with message 'Bam!' in /run_dir/repl.php(68) : eval()'d code:2 Stack trace: #0 /run_dir/repl.php(68): eval() #1 {main} Next exception 'Exception' with message 'Another!' in /run_dir/repl.php(68) : eval()'d code:4 Stack trace: #0 /run_dir/repl.php(68): eval() #1 {main} thrown
Busybox is very standard in unix today. I would recommend adding indexof, split, join & seq examples for those.
I'm pretty familiar with JavaScript & Python, trying to learn Lua. But Lua is only displayed alongside Perl & Groovy, neither of which I know. The ability to get a JavaScript, Python, Lua table would be really handy. (There are also languages in other categories, e.g. Java, that might make useful comparisons for me too, where they do overlap).
[ Hi Clark, sorry if this isn't the best place to post a message like this, but it was the best I could find...]
ECMAScript 6 contains many new features that are being implemented in JavaScript engines.
Notable features include:
https://github.com/lukehoban/es6features
https://leanpub.com/understandinges6/read/
In Brace, Tilde, Command, and Pathname Expansion, the table is correct that fish does not have a built-in way to create a sequence from 1 to 10, but I think it would be more useful and informative to replace "none" with seq 1 10
.
There's a few problems with the PHP one.
Old stuff not included:
Script encoding can be set with declare(encoding='utf-8');
but this is almost meaningless except in obscure cases
PHP also has **
instead of pow() for exponentiation
Strings can be immediately indexed since 5.6
For "replicate" under arrays, use array_fill()
For constant definition there is also const PI = 3.141592;
syntax, which is nicer
For PHP extra argument behaviour: they're ignored.
For variadic functions, there's also the ...
syntax now:
function foo($bar, ...$args) {
// $args is an array, do something
}
For the unsplat, ditto:
some_func(...$args);
Exceptions can be re-raised by throwing the caught exception.
New stuff that should be included (at least when PHP 7 is out):
intdiv($num, $div)
for proper integer division<=>
for three-value comparison\u{xxxx}
(variable number of x, supports non-BMP codepoints) Unicode codepoint escape sequencePython 3.6 added the ability to interpolate variables into strings using this syntax (following the other examples):
Variable interpolation:
count = 3
item = 'ball'
print(f'{count} {item}s')
Here documents:
word = "amet"
s = f"""lorem ipsum
dolor sit {word}"""
Expression interpolation:
f'1 + 1 = {1 + 1}'
The relevant sections should be updated to indicate these capabilities.
In the section "variables" the Go snippet reads:
// memory allocated on heap:
ptr := new(int)
*ptr = 7
This is not always true. The Go compiler does an escape analysis on the code and only if the pointer can leave the scope of the allocating function (eg. by being returned) , the allocation is done on the heap.
In Python x == None is not correct as anything that is false will make that true.
For example:
if x == None:
print 'True'
else:
print 'False'
x = 0 # True
x = 1 # False
x = [] # True
x = [1] # False
x = False # True
x = None # True
But this only works on None:
if x is None:
print 'True'
else:
print 'False'
x = 0 # False
x = 1 # False
x = [] # False
x = [1] # False
x = False # False
x = None # True
Please remove x == None as a valid way to check for None (Null) as it gives wrong information.
There seem to be several things missing in powershell vs command prompt.
For example the user id wmic useraccount where name='John' get sid
and the username echo %username%
In addition this is how you handle arguments in powershell
https://devcentral.f5.com/articles/powershell-abcs-p-is-for-parameters
Interpreted Languages, sheet one, section arithmetic and logic, sqrt -1 row, ruby column states:
raises ZeroDivisionError
should be:
(-1)**0.5
#6.123233995736766e-17+1.0i
# OR
require 'complex'
include Math
sqrt(-1)
#0+1.0i
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.