Simple Perl variables are called scalars. Examples of scalar values are
$number = 123;
$string = "String";
$file_handle = open "<filename";
$null_value = undef;
$instance = MyClass->new;| def fusc(n): | |
| """Return the nth number of Stern's diatomic series recursively""" | |
| if n == 0 or n == 1: | |
| return n | |
| elif n > 0 and n % 2 == 0: # even | |
| return fusc(n // 2) | |
| elif n > 0 and n % 2 == 1: # odd | |
| return fusc((n - 1) // 2) + fusc((n + 1) // 2) | |
| else: |
| # -------------------------------------------------------------------- | |
| # Recursive backtracking algorithm for maze generation. Requires that | |
| # the entire maze be stored in memory, but is quite fast, easy to | |
| # learn and implement, and (with a few tweaks) gives fairly good mazes. | |
| # Can also be customized in a variety of ways. | |
| # -------------------------------------------------------------------- | |
| # -------------------------------------------------------------------- | |
| # 1. Allow the maze to be customized via command-line parameters | |
| # -------------------------------------------------------------------- |
| # -*- coding: utf-8 -*- | |
| """ | |
| codegen | |
| ~~~~~~~ | |
| Extension to ast that allow ast -> python code generation. | |
| :copyright: Copyright 2008 by Armin Ronacher. | |
| :license: BSD. | |
| """ |
| # MIPS Sudoku Solver | |
| # Andrew Zich - 2011 | |
| .data | |
| sudoku: .byte 8 0 0 4 0 6 0 0 7 | |
| .byte 0 0 0 0 0 0 4 0 0 | |
| .byte 0 1 0 0 0 0 6 5 0 | |
| .byte 5 0 9 0 3 0 7 8 0 | |
| .byte 0 0 0 0 7 0 0 0 0 | |
| .byte 0 4 8 0 2 0 1 0 3 |
| Lbl G | |
| ClrHome | |
| Disp " J.M.'S DRUGWAR"," SIMULATION",""," VERSION 2.00",""," JUST SAY NO." | |
| 2000→Z | |
| 5000→Y | |
| 0→V | |
| 100→K | |
| 1→B | |
| 2→N | |
| 0→I |
| DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
| Version 2, December 2004 | |
| Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE> | |
| Everyone is permitted to copy and distribute verbatim or modified | |
| copies of this license document, and changing it is allowed as long | |
| as the name is changed. | |
| DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE |
| var p1 = { | |
| x: 20, | |
| y: 20 | |
| }; | |
| var p2 = { | |
| x: 40, | |
| y: 40 | |
| }; |
| Latency Comparison Numbers (~2012) | |
| ---------------------------------- | |
| L1 cache reference 0.5 ns | |
| Branch mispredict 5 ns | |
| L2 cache reference 7 ns 14x L1 cache | |
| Mutex lock/unlock 25 ns | |
| Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
| Compress 1K bytes with Zippy 3,000 ns 3 us | |
| Send 1K bytes over 1 Gbps network 10,000 ns 10 us | |
| Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD |
| #/*<?php eval('echo "PHP Code\n";'); __halt_compiler();?> */ | |
| #include <stdio.h> /* | |
| print ((("b" + "0" == 0) and eval('"Perl Code\n"')) or (0 and "Ruby Code\n" or "Python Code")); | |
| __DATA__ = 1 | |
| """"" | |
| __END__ |