array_push
(PHP 4, PHP 5, PHP 7)
array_push — 将一个或多个单元压入数组的末尾（入栈）
说明
int array_push ( array &$array , mixed $var [, mixed $... ] )
array_push() 将 array 当成一个栈，并将传入的变量压入 array 的末尾。array 的长度
将根据入栈变量的数目增加。和如下效果相同：
并对每个 var 重复以上动作。
Note: 如果用 array_push() 来给数组增加一个单元，还不如用 $array[] = ，因为
这样没有调用函数的额外负担。
Note: 如果第一个参数不是数组，array_push() 将发出一条警告。这和 $var[] 的行
为不同，后者会新建一个数组。
参数
array
输入的数组。
var
要压入的值。
返回值
返回处理之后数组的元素个数。
范例
Example #1 array_push() 例子
以上例程会输出：
Array
(
[0] => orange
[1] => banana
[2] => apple
[3] => raspberry
)
参见
• array_pop() - 将数组最后一个单元弹出（出栈）
• array_shift() - 将数组开头的单元移出数组
• array_unshift() - 在数组开头插入一个或多个单元
User Contributed Notes 39 notes
===============================================================================
If you're going to use array_push() to insert a "$key" => "$value" pair into an
array, it can be done using the following:
$data[$key] = $value;
It is not necessary to use array_push.
===============================================================================
I've done a small comparison between array_push() and the $array[] method and
the $array[] seems to be a lot faster.
takes 0.0622200965881 seconds
and
takes 1.63195490837 seconds
so if your not making use of the return value of array_push() its better to use
the $array[] way.
Hope this helps someone.
===============================================================================
If you're adding multiple values to an array in a loop, it's faster to use
array_push than repeated [] = statements that I see all the time:
start = microtime(true);
}
public function Finish()
{
$this->end = microtime(true);
}
private function GetStart()
{
if (isset($this->start))
return $this->start;
else
return false;
}
private function GetEnd()
{
if (isset($this->end))
return $this->end;
else
return false;
}
public function GetDiff()
{
return $this->GetEnd() - $this->GetStart();
}
public function Reset()
{
$this->start = microtime(true);
}
}
echo "Adding 100k elements to array with []\n\n";
$ta = array();
$test = new Timer();
for ($i = 0; $i < 100000; $i++)
{
$ta[] = $i;
}
$test->Finish();
echo $test->GetDiff();
echo "\n\nAdding 100k elements to array with array_push\n\n";
$test->Reset();
for ($i = 0; $i < 100000; $i++)
{
array_push($ta,$i);
}
$test->Finish();
echo $test->GetDiff();
echo "\n\nAdding 100k elements to array with [] 10 per iteration\n\n";
$test->Reset();
for ($i = 0; $i < 10000; $i++)
{
$ta[] = $i;
$ta[] = $i;
$ta[] = $i;
$ta[] = $i;
$ta[] = $i;
$ta[] = $i;
$ta[] = $i;
$ta[] = $i;
$ta[] = $i;
$ta[] = $i;
}
$test->Finish();
echo $test->GetDiff();
echo "\n\nAdding 100k elements to array with array_push 10 per iteration\n\n";
$test->Reset();
for ($i = 0; $i < 10000; $i++)
{
array_push($ta,$i,$i,$i,$i,$i,$i,$i,$i,$i,$i);
}
$test->Finish();
echo $test->GetDiff();
?>
Output
$ php5 arraypush.php
X-Powered-By: PHP/5.2.5
Content-type: text/html
Adding 100k elements to array with []
0.044686794281006
Adding 100k elements to array with array_push
0.072616100311279
Adding 100k elements to array with [] 10 per iteration
0.034690141677856
Adding 100k elements to array with array_push 10 per iteration
0.023932933807373
===============================================================================
If you push an array onto the stack, PHP will add the whole array to the next
element instead of adding the keys and values to the array. If this is not what
you want, you're better off using array_merge() or traverse the array you're
pushing on and add each element with $stack[$key] = $value.
The above will output this:
Array (
[0] => a
[1] => b
[2] => c
[3] => Array (
[0] => a
[1] => b
[2] => c
)
)
===============================================================================
If you want to preserve the keys in the array, use the following:
===============================================================================
Add elements to an array before or after a specific index or key:
$v){
if($k==$pos)$R=array_merge($R,$in);
$R[$k]=$v;
}
}return $R;
}
/**
* @return array
* @param array $src
* @param array $in
* @param int|string $pos
*/
function array_push_after($src,$in,$pos){
if(is_int($pos)) $R=array_merge(array_slice($src,0,$pos+1), $in,
array_slice($src,$pos+1));
else{
foreach($src as $k=>$v){
$R[$k]=$v;
if($k==$pos)$R=array_merge($R,$in);
}
}return $R;
}
// Examples:
$src=array("A","B","C");
$in=array("X","Y");
var_dump(array_push_before($src,$in,1));
/* array_push_before, no-key array
array(5) {
[0]=>
string(1) "A"
[1]=>
string(1) "X"
[2]=>
string(1) "Y"
[3]=>
string(1) "B"
[4]=>
string(1) "C"
}*/
var_dump(array_push_after($src,$in,1));
/* array_push_after, no-key array
array(5) {
[0]=>
string(1) "A"
[1]=>
string(1) "B"
[2]=>
string(1) "X"
[3]=>
string(1) "Y"
[4]=>
string(1) "C"
}*/
$src=array('a'=>"A",'b'=>"B",'c'=>"C");
$in=array('x'=>"X",'y'=>"Y");
var_dump(array_push_before($src,$in,1));
/* array_push_before, key array, before index insert
array(5) {
["a"]=>
string(1) "A"
["x"]=>
string(1) "X"
["y"]=>
string(1) "Y"
["b"]=>
string(1) "B"
["c"]=>
string(1) "C"
}*/
var_dump(array_push_before($src,$in,'b'));
/* array_push_before, key array, before key insert
array(5) {
["a"]=>
string(1) "A"
["x"]=>
string(1) "X"
["y"]=>
string(1) "Y"
["b"]=>
string(1) "B"
["c"]=>
string(1) "C"
}*/
var_dump(array_push_after($src,$in,1));
/* array_push_after, key array, after index insert
array(5) {
["a"]=>
string(1) "A"
["b"]=>
string(1) "B"
["x"]=>
string(1) "X"
["y"]=>
string(1) "Y"
["c"]=>
string(1) "C"
}*/
var_dump(array_push_after($src,$in,'b'));
/* array_push_after, key array, after key insert
array(5) {
["a"]=>
string(1) "A"
["b"]=>
string(1) "B"
["x"]=>
string(1) "X"
["y"]=>
string(1) "Y"
["c"]=>
string(1) "C"
}*/
?>
===============================================================================
elegant php array combinations algorithm
//by Shimon Dookin
function get_combinations(&$lists,&$result,$stack=array(),$pos=0)
{
$list=$lists[$pos];
if(is_array($list))
foreach($list as $word)
{
array_push($stack,$word);
if(count($lists)==count($stack))
$result[]=$stack;
else
get_combinations($lists,$result,$stack,$pos+1);
array_pop($stack);
}
}
$wordlists= array( array("shimon","doodkin") , array("php programmer","sql
programmer","mql metatrader programmer") );
get_combinations($wordlists,$combinations);
echo '
';
print_r($combinations);
?>
===============================================================================
This will work to solve the associative array issues:
$aValues[$key] = $value;
Where $key is a unique identifier and $value is the value to be stored. Since
the $key works off a string or number, if you already have a $key with the same
value as an existing $key, the element will be overwritten.
e.g.
$aValues["one"] = "value of one";
$aValues["two"] = "different value of two!";
gives:
array([one] => "value of one", [two] => "value of two");
but will be overwritten when using the same key (one):
$aValues["one"] = "value of one";
$aValues["one"] = "different value of two!";
will give:
array([one] => "different value of two!");
3686
===============================================================================
A function which mimics push() from perl, perl lets you push an array to an
array: push(@array, @array2, @array3). This function mimics that behaviour.
0) {
array_unshift($v, &$arr);
call_user_func_array('array_push', $v);
}
} else {
$arr[] = $v;
}
}
return count($arr);
}
$arr = array(0);
$arr2 = array(6,7,8);
printf("%s\n", array_push_array($arr, array(),array(1,2,3,4,5), $arr2));
print_r($arr);
# error..
$arr = "test";
printf("%s\n", array_push_array($arr, array(),array(1,2,3,4,5), $arr2));
?>
===============================================================================
A small and basic implementation of a stack without using an array.
class node
{
var $elem;
var $next;
}
class stack
{
var $next;
function pop()
{
$aux=$this->next->elem;
$this->next=$this->next->next;
return $aux;
}
function push($obj)
{
$nod=new node;
$nod->elem=$obj;
$nod->next=$this->next;
$this->next=$nod;
}
function stack()
{
$this->next=NULL;
}
}
===============================================================================
Need a real one-liner for adding an element onto a new array name?
$emp_list_bic = $emp_list + array(c=>"ANY CLIENT");
CONTEXT...
drewdeal: this turns out to be better and easier than array_push()
patelbhadresh: great!... so u discover new idea...
drewdeal: because you can't do: $emp_list_bic = array_push($emp_list, c=>"ANY
CLIENT");
drewdeal: array_push returns a count and affects current array.. and does not
support set keys!
drewdeal: yeah. My one-liner makes a new array as a derivative of the prior
array
===============================================================================
If you want to put an element to a specific position in an array, try this
function.
$v)
{
// insert new object
if ($count == $position)
{
if (!$name) $name = $count;
$return[$name] = $object;
$inserted = true;
}
// insert old object
$return[$k] = $v;
$count++;
}
if (!$name) $name = $count;
if (!$inserted) $return[$name];
$array = $return;
return $array;
}
?>
Example :
'A',
'b' => 'B',
'c' => 'C',
);
print_r($a);
array_put_to_position($a, 'G', 2, 'g');
print_r($a);
/*
Array
(
[a] => A
[b] => B
[c] => C
)
Array
(
[a] => A
[b] => B
[g] => G
[c] => C
)
*/
?>
===============================================================================
Rodrigo de Aquino asserted that instead of using array_push to append to an
associative array you can instead just do...
$data[$key] = $value;
...but this is actually not true. Unlike array_push and even...
$data[] = $value;
...Rodrigo's suggestion is NOT guaranteed to append the new element to the END
of the array. For instance...
$data['one'] = 1;
$data['two'] = 2;
$data['three'] = 3;
$data['four'] = 4;
...might very well result in an array that looks like this...
[ "four" => 4, "one" => 1, "three" => 3, "two" => 2 ]
I can only assume that PHP sorts the array as elements are added to make it
easier for it to find a specified element by its key later. In many cases it
won't matter if the array is not stored internally in the same order you added
the elements, but if, for instance, you execute a foreach on the array later,
the elements may not be processed in the order you need them to be.
If you want to add elements to the END of an associative array you should use
the unary array union operator (+=) instead...
$data['one'] = 1;
$data += [ "two" => 2 ];
$data += [ "three" => 3 ];
$data += [ "four" => 4 ];
You can also, of course, append more than one element at once...
$data['one'] = 1;
$data += [ "two" => 2, "three" => 3 ];
$data += [ "four" => 4 ];
Note that like array_push (but unlike $array[] =) the array must exist before
the unary union, which means that if you are building an array in a loop you
need to declare an empty array first...
$data = [];
for ( $i = 1; $i < 5; $i++ ) {
$data += [ "element$i" => $i ];
}
...which will result in an array that looks like this...
[ "element1" => 1, "element2" => 2, "element3" => 3, "element4" => 4 ]
===============================================================================
Unfortunately array_push returns the new number of items in the array
It does not give you the key of the item you just added, in numeric arrays you
could do -1, you do however need to be sure that no associative key exists as
that would break the assumption
It would have been better if array_push would have returned the key of the item
just added like the below function
(perhaps a native variant would be a good idea...)
\n";
$pr = array('foo'=>'bar','bar'=>'foo');
echo "Taken array;";
print_r($pr);
echo "\npush 1 returns ".array_push($pr,1)."\n";
echo "------------------------------------\n";
$pr = array('foo'=>'bar','bar'=>'foo');
echo "\npush 2 returns ".array_push($pr,1,2)."\n";
echo "------------------------------------\n";
$pr = array('foo'=>'bar','bar'=>'foo');
echo "\n add 1 returns ".array_add($pr,2)."\n\n";
echo "------------------------------------\n";
$pr = array('foo'=>'bar','bar'=>'foo');
echo "\n add 2 returns ".array_add($pr,1,2)."\n\n";
echo "\n\n";
?>
Outputs:
Taken array;Array
(
[foo] => bar
[bar] => foo
)
push 1 returns 3
------------------------------------
push 2 returns 4
------------------------------------
add 1 returns 0
------------------------------------
add 2 returns 1
===============================================================================
I did a performance check, and I saw, if you push more than one value it can be
faster the array push, that the normal $array[] version.
Case 1: $array[] = something;
Case 2: array_push($array, $value);
Case 3: array_push($array, $value1, $value2, $value3 [...]); $values are
definied
Case 4: array_push($array, $value1, $value2, $value3 [...]); $values are
definied, when $array is not empty
Case 5: Case1 + Case 3
Case 6: Result array contains some value (Case 4)
Case 7: Result array contains same value as the push array (Case 4)
-----------------------------------------------------------------------------------------------------------
~~~~~~~~~~~~ Case 1 ~~~~~~~~~~~~
Times: 0.0310 0.0300 0.0290 0.0340 0.0400 0.0440 0.0480 0.0550 0.0570 0.0570
Min: 0.0290
Max: 0.0570
Avg: 0.0425
~~~~~~~~~~~~ Case 2 ~~~~~~~~~~~~
Times: 0.3890 0.3850 0.3770 0.4110 0.4020 0.3980 0.4020 0.4060 0.4130 0.4200
Min: 0.3770
Max: 0.4200
Avg: 0.4003
~~~~~~~~~~~~ Case 3 ~~~~~~~~~~~~
Times: 0.0200 0.0220 0.0240 0.0340 0.0360 0.0410 0.0460 0.0500 0.0520 0.0520
Min: 0.0200
Max: 0.0520
Avg: 0.0377
~~~~~~~~~~~~ Case 4 ~~~~~~~~~~~~
Times: 0.0200 0.0250 0.0230 0.0260 0.0330 0.0390 0.0460 0.0510 0.0520 0.0520
Min: 0.0200
Max: 0.0520
Avg: 0.0367
~~~~~~~~~~~~ Case 5 ~~~~~~~~~~~~
Times: 0.0260 0.0250 0.0370 0.0360 0.0390 0.0440 0.0510 0.0520 0.0530 0.0560
Min: 0.0250
Max: 0.0560
Avg: 0.0419
~~~~~~~~~~~~ Case 6 ~~~~~~~~~~~~
Times: 0.0340 0.0280 0.0370 0.0410 0.0450 0.0480 0.0560 0.0580 0.0580 0.0570
Min: 0.0280
Max: 0.0580
Avg: 0.0462
~~~~~~~~~~~~ Case 7 ~~~~~~~~~~~~
Times: 0.0290 0.0270 0.0350 0.0410 0.0430 0.0470 0.0540 0.0540 0.0550 0.0550
Min: 0.0270
Max: 0.0550
Avg: 0.044
Tester code:
// Case 1
$startTime = microtime(true);
$array = array();
for ($x = 1; $x <= 100000; $x++)
{
$array[] = $x;
}
$endTime = microtime(true);
// Case 2
$startTime = microtime(true);
$array = array();
for ($x = 1; $x <= 100000; $x++)
{
array_push($array, $x);
}
$endTime = microtime(true);
// Case 3
$result = array();
$array2 = array(&$result)+$array;
$startTime = microtime(true);
call_user_func_array("array_push", $array2);
$endTime = microtime(true);
// Case 4
$result = array();
for ($x = 1; $x <= 100000; $x++)
{
$result[] = $x;
}
$array2 = array(&$result)+$array;
$startTime = microtime(true);
call_user_func_array("array_push", $array2);
$endTime = microtime(true);
// Case 5
$result = array();
$startTime = microtime(true);
$array = array(&$result);
for ($x = 1; $x <= 100000; $x++)
{
$array[] = $x;
}
$endTime = microtime(true);
// Case 6
$result = array(1,2,3,4,5,6);
$startTime = microtime(true);
$array = array(&$result);
for ($x = 1; $x <= 100000; $x++)
{
$array[] = $x;
}
$endTime = microtime(true);
// Case 7
$result = array();
for ($x = 1; $x <= 100000; $x++)
{
$result[] = $x;
}
$startTime = microtime(true);
$array = array(&$result);
for ($x = 1; $x <= 100000; $x++)
{
$array[] = $x;
}
$endTime = microtime(true);
===============================================================================
===============================================================================
Be warned using $array "+=" array(1,2,3) or union operations (http://php.net/
manual/en/language.operators.array.php)
I think it worked in the past or i havent test it good enough. :-/
(once it worked, once [] was faster than array_push, the past :-D ):
php -r '$a = array(1,2); $a += array(3,4); print_r($a);'
Array (
[0] => 1
[1] => 2
)
php -r '$a = array(1,2); $b = array(3,4);$c = $a + $b; print_r($c);'
Array (
[0] => 1
[1] => 2
)
php -r '$a = array(1,2); $b = array(2=>3,3=>4);$c = $a + $b; print_r($c);'
Array (
[0] => 1
[1] => 2
[2] => 3
[3] => 4
)
===============================================================================
I found a simple way to have an "array_push_array" function, without the
references problem when we want to use call_user_func_array(), hope this help :
function array_push_array(array &$array)
{
$numArgs = func_num_args();
if(2 > $numArgs)
{
trigger_error(sprintf('%s: expects at least 2 parameters, %s given',
__FUNCTION__, $numArgs), E_USER_WARNING);
return false;
}
$values = func_get_args();
array_shift($values);
foreach($values as $v)
{
if(is_array($v))
{
if(count($v) > 0)
{
foreach($v as $w)
{
$array[] = $w;
}
}
}
else
{
$array[] = $v;
}
}
return count($array);
}
===============================================================================
This function "Returns the new number of elements in the array."
To find out the last index, use:
===============================================================================
I wrote this function for use with 'latest scores' on a quiz site, but it has
many potential uses.
$limit);
return $array;
}
?>
----------
EXAMPLE:
----------
----------
OUTPUT:
----------
Array
(
[0] => 33
[1] => 54
[2] => 3
[3] => HELLO
)
===============================================================================
A very good function to remove a element from array
function array_del($str,&$array)
{
if (in_array($str,$array)==true)
{
foreach ($array as $key=>$value)
{
if ($value==$str) unset($array[$key]);
}
}
}
===============================================================================
Just a typo i think but the code below will actually produce
Array
(
[0] => a
[1] => b
[2] => c
[3] => Array
(
[0] => d
[1] => e
[2] => f
)
)
===============================================================================
Further Modification on the array_push_associative function
1. removes seemingly useless array_unshift function that generates php warning
2. adds support for non-array arguments
// Append associative array elements
function array_push_associative(&$arr) {
$args = func_get_args();
foreach ($args as $arg) {
if (is_array($arg)) {
foreach ($arg as $key => $value) {
$arr[$key] = $value;
$ret++;
}
}else{
$arr[$arg] = "";
}
}
return $ret;
}
$items = array("here" => "now");
$moreitems = array("this" => "that");
$theArray = array("where" => "do we go", "here" => "we are today");
echo array_push_associative($theArray, $items, $moreitems, "five") . ' is the
size of $theArray.
';
echo "";
print_r($theArray);
echo "
";
?>
Yields:
4 is the size of $theArray.
Array
(
[where] => do we go
[here] => now
[this] => that
[five] =>
)
===============================================================================
Looking for a way to push data into an associative array and frustrated to know
that array_push() can't do the job ?
here's my Scenario :
-------------------
I need to relate system command output into an associative array like these :
[sge@digital_db work]$ /usr/local/apache/htdocs/work/qhost.sh -h t1 -F | awk '
{if(NR>4) print $1}' | sed 's/hl://g'
arch=lx24-amd64
num_proc=2.000000
mem_total=3.808G
swap_total=3.907G
virtual_total=7.715G
load_avg=0.000000
load_short=0.000000
load_medium=0.000000
load_long=0.000000
mem_free=3.510G
swap_free=3.907G
virtual_free=7.417G
mem_used=305.242M
swap_used=0.000
virtual_used=305.242M
cpu=0.000000
np_load_avg=0.000000
np_load_short=0.000000
np_load_medium=0.000000
np_load_long=0.000000
how I did it :
php
# get into the system command output
$assoc_cmd =`$work_dir/qhost.sh -h $host_resource -F | awk '{if(NR>4) print $1}
'| sed 's/hl://g' ` ;
# split the "\n" character
$assoc_row = explode("\n", chop($assoc_cmd));
# get the index row
$idx_row = count($assoc_row) - 1 ;
# initialize the associative array
$host_res_array = array();
for ($i = 0 ; $i<= $idx_row ; $i++)
{
# get params & values
list($host_param,$host_val) = explode("=",$assoc_row[$i]);
# populate / push data to assoc array
$host_res_array[$host_param]= $host_val ;
}
echo " Architecture :
\n" ;
echo $host_res_array['arch'] ;
echo " Mem Total :
\n" ;
echo $host_res_array['mem_tot'];
?>
Hope this helps ! :)
===============================================================================
regarding the speed of oneill's solution to insert a value into a
non-associative array, I've done some tests and I found that it behaves well
if you have a small array and more insertions, but for a huge array and a
little insersions I sugest using this function:
function array_insert( &$array, $index, $value ) {
$cnt = count($array);
for( $i = $cnt-1; $i >= $index; --$i ) {
$array[ $i + 1 ] = $array[ $i ];
}
$array[$index] = $value;
}
or if you are a speed adicted programmer (same situation: big array, few
insertions) use this:
array_splice ( $array, $offset, 0, $item );
item may also be an array of values ;).
===============================================================================
As someone pointed out the array_push() function returns the count of the array
not the key of the new element. As it was the latter function i required i
wrote this very simple replacement.
function array_push2(&$array,$object,$key=null){
$keys = array_keys($array);
rsort($keys);
$newkey = ($key==null)?$keys[0]+1:$key;
$array[$newkey] = $object;
return $newkey;
}
===============================================================================
To insert a value into a non-associative array, I find this simple function
does the trick:
function insert_in_array_pos($array, $pos, $value)
{
$result = array_merge(array_slice($array, 0 , $pos), array($value),
array_slice($array, $pos));
return $result;
}
Seems an awful lot simpler than the iterative solutions given above...
===============================================================================
Skylifter notes on 20-Jan-2004 that the [] empty bracket notation does not
return the array count as array_push does. There's another difference between
array_push and the recommended empty bracket notation.
Empy bracket doesn't check if a variable is an array first as array_push does.
If array_push finds that a variable isn't an array it prints a Warning message
if E_ALL error reporting is on.
So array_push is safer than [], until further this is changed by the PHP
developers.
===============================================================================
However, don't forget that array_push() does more than [], it also performs a
count and returns the value.
Modifying your code ever so slightly (see below), this puts array_push in the
lead (not suprisingly). So my conclusion would be that if I care about the
number of elements in the array, then I'd use array_push(), if I don't (which
is usually the case), then I'd use the [] method.
Results...
[] method: 0.34943199
push method: 0.31505919
difference: -0.03437280
Modified section of code...
$s_test_begin = FullMicroTime();
for($i = 0; $i <= 50000; $i++) { $num_tot = array_push($test2, $i); }
$s_test_end = FullMicroTime();
$f_test_begin = FullMicroTime();
for($i = 0; $i <= 50000; $i++) { $test[] = $i; $num_tot = count($test); }
$f_test_end = FullMicroTime();
===============================================================================
Array_push also works fine with multidimensional arrays. Just make sure the
element is defined as an array first.
===============================================================================
Previous comment was not fully imitating the array_push behaviour,
1) does not return number of items pushed
2) can only handle one array to push
> Revised associative_push function with absolute reference of arg1 array; left
unchanged if arg2 is empty.
$value) {
$arr[$key] = $value;
$ret++;
}
}
}
return $ret;
}
$theArray = array();
echo array_push_associative($theArray, $items, $moreitems) . ' items added to
$theArray.';
?>
===============================================================================
The problem with array_push is that it is pass by value. If you are dealing
with objects whose inner state may change at any time, you need a push and pop
who return the actual objects, rather than copies of them.
After some difficulty and board assistance, I have these methods. I've tested
them, and they seem to work fine.
value;
}
function setValue($mixed){
$this->value = $mixed;
}
}
$myarr = array();
$tmp =& new TestObject();
$tmp2 =& new TestObject();
$tmp->setValue(2);
$tmp2->setValue(3);
push($myarr, $tmp);
push($myarr, $tmp2);
$tmp->setValue(4);
$tmp2->setValue(6);
$val = pop($myarr);
print "popped value: ".$val->getValue()."
";
print "values in internal array:
";
foreach ($myarr as $key=>$value){
print "key: $key, object: $value, value: ";
print $value->getValue()."
";
}
// [/TestCode]
?>
===============================================================================
If you need to push the elements of an array onto the end of another, simply
use array_splice():
array_splice($array, count($array), 0, $otherArray);
===============================================================================
A variation of kamprettos' associative array push:
// append associative array elements
function associative_push($arr, $tmp) {
if (is_array($tmp)) {
foreach ($tmp as $key => $value) {
$arr[$key] = $value;
}
return $arr;
}
return false;
}
$theArray = array();
$theArray = associative_push($theArray, $items);
===============================================================================
With multidimensional arrays it's easy too (somebody posted a sample, but it
isn't useful for beginners). Here is a piece of code that should explain
everything and much more:
name = $name;
}
}
class Org2 {
public $name;
public function __construct($name) {
$this->name = $name;
}
}
//main array
$arr = array();
//creating first subarray manually
//the subarray name must be like first class above
$arr['Org'] = array();
//creating second subarray for objects of selected class
//in another way
$x=2222; //only for creating the sample object
$arr[get_class(new Org2("wtf".$x))] = array();
//pushing some new objects to (sub)arrays in (main)array
for ($i=0; $i<3; $i++) {
$org1 = new Org("tst".$i);
$org2 = new Org2("wtf".$i);
array_push($arr[get_class($org1)], $org1);
array_push($arr[get_class($org2)], $org2);
}
//printing everything
foreach ($arr as $key=>$value) {
$counter = 0;
echo "=====".$key." (key) | value: ".$value."
";
foreach ($value as $key2=>$value2) {
if($value2 == null) {
//echo "counter: ".$counter." | key: ".$key2;
unset($arr[$key][$key2]);
} else {
print_r($value2);
echo " [".$counter."] [".$key2."]
";
}
$counter++;
}
}
//the additional, second part
echo "
--------
";
//deleting one of the objects from selected (sub)array
unset($arr['Org'][1]);
//printing everything again (look at the counter values)
foreach ($arr as $key=>$value) {
$counter = 0;
echo "=====".$key." (key) | value: ".$value."
";
foreach ($value as $key2=>$value2) {
if($value2 == null) {
//echo "counter: ".$counter." | key: ".$key2;
unset($arr[$key][$key2]);
} else {
print_r($value2);
echo " [".$counter."] [".$key2."]
";
}
$counter++;
}
}
?>
What we get in browser/console:
=====Org (key) | value: Array
Org Object ( [name] => tst0 ) [0] [0]
Org Object ( [name] => tst1 ) [1] [1]
Org Object ( [name] => tst2 ) [2] [2]
=====Org2 (key) | value: Array
Org2 Object ( [name] => wtf0 ) [0] [0]
Org2 Object ( [name] => wtf1 ) [1] [1]
Org2 Object ( [name] => wtf2 ) [2] [2]
--------
=====Org (key) | value: Array
Org Object ( [name] => tst0 ) [0] [0]
Org Object ( [name] => tst2 ) [1] [2]
=====Org2 (key) | value: Array
Org2 Object ( [name] => wtf0 ) [0] [0]
Org2 Object ( [name] => wtf1 ) [1] [1]
Org2 Object ( [name] => wtf2 ) [2] [2]
===============================================================================
Note that array_push() will, as described, return the COUNT of the array after
adding a new item, not necessarily the INDEX of that new item:
'three', 5 => 'five');
echo "\$array = ";
print_r($array);
echo "\n\n";
$to_push = array(1,2,4,);
foreach($to_push as $var)
{
echo "calling array_push(\$array,$var); retval is ";
echo array_push($array,$var);
echo "\n";
}
echo "\$array = ";
print_r($array);
?>
The output of above is:
$array = Array
(
[3] => three
[5] => five
)
calling array_push($array,1); retval is 4
calling array_push($array,2); retval is 5
calling array_push($array,4); retval is 6
$array = Array
(
[3] => three
[5] => five
[7] => seven
[8] => 1
[9] => 2
[10] => 4
)
Notice how when array_push($array,1) was called, the new element has a key of 8
but array_push() returns 4.
===============================================================================
I noticed that under certain circumstances it can be faster to use
&$array1) + array_values(
$array2));
?>
than
$value) {
$array1[] = $value;
}
?>
===============================================================================
Sadly, array_push() does not create an array if the array doesn't exist. So if
you're pushing the first element onto an array, you need to check and create it
manually...
===============================================================================
i wanted to do some string manipulation on a specific field from an sql result
set and then append the row to the end of an array like this.
[0] =>
[one] => [val1]
[two] => [val2]
[three] => [val3]
[four] => [val4]
[0] =>
[one] => [val1]
[two] => [val2]
[three] => [val3]
[four] => [val4]
~I tried array push and couldnt get it sorted, So what i did was this.
while ($row = mysql_fetch_assoc($query)) {
$row['five'] = str_replace('.','',$row['place']);
$results[] = $row;
}
resulting in
[0] =>
[one] => [val1]
[two] => [val2]
[three] => [val3]
[four] => [val4]
[five] => [val5]
[0] =>
[one] => [val1]
[two] => [val2]
[three] => [val3]
[four] => [val4]
[five] => [val5]


Thousands turn out for Halesowen's Christmas lights switch-on - with VIDEO
Christmas was sparked into life in Halesowen as thousands of people attended the town's annual lights switch-on.
by Jamie BrassingtonThe honours were carried out by Line of Duty actor Gregory Piper, 21, who is from also Halesowen.
He was joined on stage by Dudley's deputy mayor Hilary Bills - a Halesowen ward councillor - and local school pupil Pheobe Glover, who won a competition to be on stage for the event.
Crowds were treated to a host of entertainment. There was live performances from acts including Bhangra Smash Up and Andy Bennett of Ocean Colour Scene fame. The festive fun also included free children's rides, a Christmas food and craft market and an appearance by Father Christmas.
More than 5,000 people attended Somers Square.
Councillor Bills said: "The Christmas countdown has well and truly begun in Halesowen!
"It was a pleasure to join Gregory on stage today, he is a true home-grown talent and our borough is rightly proud of his achievements and notoriety.
"The event was really well supported by the residents and I especially want to thank Halesowen BID (Business Improvement District) for making events in the town like this possible."
More events:
Dudley light switch-on takes place Saturday November 23 from 12 noon to 5pm, Brierley Hill’s event is Friday November 29 from 3pm to 6pm and Stourbridge’s event is on Saturday November 30 from 9am to 5pm.


HIV trial trials ART UTT care study health years South [cited collab: from: population Available Dec AIDS Health intervention testing research national treatment impact initiation UNAIDS universal Africa communities Africa. SEARCH TasP data (e.g. ANRS services baseline community interventions prevention arm incidence {border-style Botswana PopART Trial World aged px;} #ffffff;} ;Suppl Research Uganda antiretroviral ;():–. BCPP old :–. Care. Kenya Med. Phase models sub�?Saharan viral MaxART National Population Table Zambia early including therapy trial)[], arms olda outcomes trial. Ministry control delivered information months primary trial, Global N.A. Organization activities and/or care, eligibility informed policy public randomized results rural strategies trials. Gave Institute Prevention SA: Swaziland consent criteria evidence member population�?level present reduction studies suppression (ANRS African Community Orne�?GliemannJ, United characteristics clinical combination comparison design implementation individual individuals local new offered px; standard targets time {font-family �?�? > Africa: Bank HIV�? HIV�?infected Kingdom Poverty Statistics Universal University access assessment cascade collected context contexts differences epidemic experiences follow�?up font-size key lines living participants phase poverty prevalence screening social test < (GARPR) (unpublished ;():e. Africa, Country Evaluation Intervention IwujiC, Labour PrEP, Progress Report Response School States Test Wiley analysis approaches area clinic cluster cluster�?randomized common cumulative data). different double; estimated estimates factsheets feasibility geographical integrated level linkage mobile ongoing parameters potential prior provide provides statistical strategy systems testing, themes trials, (%) (BCPP, (C) (ClinicalTrials.gov (Phase), (PopART) (or ART, Demographic Department Dis. Eastern Finally, HPTN Health, Infect Infectious John KwaZulu�?Natal, Lancet Located Ltd, Medical NCT, Rural Services Sons, Survey Swaziland. TanserF, [IQR: adults aim assess available average based border-color border-width cells/μl chronic clusters collaborative community�?level comparative conducted cost counselling count coverage critical delivery design, differ differentiated especially facility future government guidelines headcount home�?based immediate improve number outcome populations pre�?exposure profile. provided range ratio retention secondary service services, site sites solid; support targeted transmission treat understanding use verbal versus {font-style {font-weight (BCPP (DHS) (SEARCH), (average (estimated ;:. Arm BarnighausenT, ChamieG, Clin Consortium Control Cumulative Delphine Disease Diseases Engl Gates Gilead HIV. HIV�?negative HIV�?positive HayesR, Housing Impact International June Kenya, LarmarangeJ, Matching: Melinda Ministries PopART, Public RNA Statistical TasP, Treat UTC Uganda. Viral Zambia. according adherence adopting areas bold care. challenges circumcision clinics collection commonalities community�?based contexts, contexts. courier; data, delivery, designed designs designs, disease effects em; evaluate explored extracted findings focus global guidelines. help high home i.e. implemented important indicators infection infection. infections initiation, insights large�?scale main manuscript needs observed oldb oldc operational overall packages, participant people population: possible pt;} qualitative questions regardless reported role status status; streamlined suppressed surveys, taking treating trial; trials' various voluntary written year �?.


This chapter, moreso than the rest of this manual, is very much a work in progress.
If you need help with plugin development, sign up on the devel mailing list and/or join us on #pyblosxom on irc.freenode.net. More details in Project details, contact information, and where to go for help.
FIXME - this needs more work
This section covers things that all plugins should have. This makes plugins easier to distribute, maintain, update, and easier for users to use them.
All plugins need a good name that’s unique so that your plugin doesn’t get confused with other plugins. Additionally, the filename for your plugin needs to be unique.
Warning
Make sure the filename for your plugin is unique! Pyblosxom imports your plugin using Python import machinery which means that if your plugin has the same name as a package on your system, then depending on how sys.path is set up, Pyblosxom may load the package on your system and NOT your plugin.
If you think this might be happening to you, do pyblosxom-cmd test and it’ll tell you the paths of what it’s loading.
All plugins should have a docstring at the top of the file that describes in detail:
For example, this is at the top of Will’s wbgpager plugin:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | """
Quickly written plugin for paging long index pages.
Pyblosxom uses the num_entries configuration variable to prevent
more than num_entries being rendered by cutting the list down
to num_entries entries. So if your num_entries is set to 20, you
will only see the first 20 entries rendered.
The wbgpager overrides this functionality and allows for paging.
It does some dirty stuff so that Pyblosxom doesn't cut the list down
and then wbgpager cuts it down in the prepare callback later down
the line.
To install wbgpager, do the following:
1. add "wbgpager" to your load_plugins list variable in your
config.py file---make sure it's the first thing listed so
that it has a chance to operate on the entry list before
other plugins.
2. add the $page_navigation variable to your head or foot
(or both) templates. this is where the page navigation
HTML will appear.
Here are some additional configuration variables to adjust the
behavior:
wbgpager_count_from
datatype: int
default value: 0
description: Some folks like their paging to start at 1---this
enables you to do that.
wbgpager_previous_text
datatype: string
default value: <<
description: Allows you to change the text for the prev link.
wbgpager_next_text
datatype: string
default value: >>
description: Allows you to change the text for the next link.
wbgpager_linkstyle
datatype: integer
default value: 0
description: This allows you to change the link style of the paging.
style 0: [1] 2 3 4 5 6 7 8 9 ... >>
style 1: Page 1 of 4 >>
That should be it!
Note: This plugin doesn't work particularly well with static rendering.
The problem is that it relies on the querystring to figure out which
page to show and when you're static rendering, only the first page
is rendered. This will require a lot of thought to fix. If you are
someone who is passionate about fixing this issue, let me know.
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify,
merge, publish, distribute, sublicense, and/or sell copies of the
Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Copyright 2004, 2005, 2006 Will Kahn-Greene
"""
|
All plugins should have the following module-level variables defined in them just after the docstring:
For example:
__author__ = "Will Kahn-Greene - willg at bluesock dot org"
__version__ = "version 1.5 2006-01-15"
__url__ = "http://www.bluesock.org/~willg/pyblosxom/"
__description__ = "Splits long indexes into multiple pages."
After that, you should have a verify_installation section that verifies that the plugin is configured correctly. As of Pyblosxom 0.9, Pyblosxom allows users to test their configuration and installation from the console.
You can test using either the pyblosxom.cgi script or the pyblosxom-cmd script:
% ./pyblosxom.cgi test
or:
$ ./pyblcmd_dev.sh test --config ./newblog/
pyblosxom-cmd version 1.5 dev
Adding ./newblog/ to sys.path....
Trying to import the config module....
System Information
==================
- pyblosxom: 1.5 dev
- sys.version: 2.6.4 (r264:75706, Dec 7 2009, 18:45:15) [GCC 4.4.1]
- os.name: posix
- codebase: /home/willg/projects/pyblosxom/trunk/pyblosxom
Checking config.py file
=======================
- properties set: 21
- datadir '/home/willg/projects/pyblosxom/testing/newblog/entries' exists.
Checking plugin configuration
=============================
....
This goes through and verifies the properties in the config.py file as best as it can. It also prints out diagnostic information which is useful when things don’t work. It also loads and initializes all the plugins and asks them to verify their configurations as best they can.
As a plugin developer, you should add a verify_installation function to your plugin module. Something like this (taken from pycategories):
1 2 3 4 5 6 7 8 9 | def verify_installation(request):
config = request.get_configuration()
if not config.has_key("category_flavour"):
print "missing optional config property 'category_flavour' "
print "which allows you to specify the flavour for the category "
print "link. refer to pycategory plugin documentation for more "
print "details."
return 1
|
This gives you (the plugin developer) the opportunity to walk the user through configuring your highly complex, quantum-charged, turbo plugin in small baby steps without having to hunt for where their logs might be.
So check the things you need to check, print out error messages (informative ones) using print, and then return a 1 if the plugin is configured correctly or a 0 if it’s not configured correctly.
Note
This is not a substitute for the user to read the installation instructions. It should be a really easy way to catch a lot of potential problems without involving the web server’s error logs and debugging information being sent to a web-browser and things of that nature.
Here’s an example of verify_installation from Will’s wbgpager plugin:
1 2 3 4 5 6 7 8 9 10 11 | def verify_installation(request):
config = request.get_configuration()
if config.get("num_entries", 0) == 0:
print "missing config property 'num_entries'. wbgpager won't do "
print "anything without num_entries set. either set num_entries "
print "to a positive integer, or disable the wbgpager plugin."
print "see the documentation at the top of the wbgpager plugin "
print "code file for more details."
return 0
return 1
|
First you need to get the logger instance. After that, you can call debug, info, warning, error and critical on the logger instance. For example:
1 2 3 4 5 6 7 8 9 10 11 12 | from pyblosxom import tools
def cb_prepare(args):
# ...
logger = tools.get_logger()
logger.info("blah blah blah...")
try:
pass
# ...
except ValueError, e:
logger.error(e)
|
The easiest way to store state between callbacks is to store the data in the data dict of the Request object. For example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | STATE_KEY = "myplugin_state"
def cb_date_head(args):
request = args["request"]
data = request.get_data()
if ((data.has_key(STATE_KEY)
and data[STATE_KEY]["blah"] == "blahblah")):
pass
# ...
def cb_filelist(args):
request = args["request"]
data = request.get_data()
data[STATE_KEY] = {}
data[STATE_KEY]["blah"] = "blahblah"
|
If you want to implement a callback, you add a function corresponding to the callback name to your plugin module. For example, if you wanted to modify the Request object just before rendering, you’d implement cb_prepare like this:
def cb_prepare(args):
pass
Obviously, since we have pass we’re not actually doing anything here, but when the user sends a request and Pyblosxom handles it, this function in your plugin will get called when Pyblosxom runs the prepare callback.
Each callback passes in arguments through a single dictionary. Each callback passes in different arguments and expects different return values. Check the doc:dev_architecture <architecture> chapter for a list of all the callbacks that are available, their arguments, and return values.
Entry parsing functions take in a filename and the Request object. They then open the file and parse it out. They can call cb_preformat and cb_postformat as they see fit. They should return a dict containing at least "title" and "body" keys. The “title” should be a single string. The "body" should be a single string and should be formatted in HTML.
Here’s an example code that reads .plain files which have the title as the first line, metadata lines that start with # and then after all the metadata the body of the entry:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | import os
def cb_entryparser(entryparsingdict):
"""
Register self as plain file handler
"""
entryparsingdict["plain"] = parse
return entryparsingdict
def parse(filename, request):
"""
We just read everything off the file here, using the filename
as the title.
"""
entrydata = {}
f = open(filename, "r")
lines = f.readlines()
f.close()
entrydata["title"] = filename
entrydata["body"] = "
" + "".join(lines) + "
"
return entrydata
|
You can also specify the template to use by setting the "template_name" variable in the returned dict. If the template specified doesn’t exist, Pyblosxom will use the story template for the specified flavour.
For example, if you were creating a tumblelog and the file parsed was a image entry and you want image entries to be displayed on your blog with an image and then a caption below it and that’s it, then you would create a template for that and set "template_name" to the name of the template:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | def cb_entryparser(entryparsingdict):
"""
Register self as plain file handler
"""
entryparsingdict['image'] = parse_image
return entryparsingdict
def parse_image(filename, request):
"""
An image entry consists of an image file name followed by
the caption. Like this::
cimg_8229.jpg
This is a picture of me standing on my head.
Note that there's no title, no metadata, ...
"""
entrydata = {}
f = open(filename, "r")
lines = f.readlines()
f.close()
# we do this for RSS purposes
entrydata['title'] = "image %s" % lines[0]
entrydata['body'] = "\n".join([
"",
"
%s
" % "".join(lines[1:])
])
entrydata["template_name"] = "image_post"
return entrydata
|
FIXME - need more about preformatters here
A typical preformatter plugin looks like this:
1 2 3 4 5 6 7 8 9 | def cb_preformat(args):
if args['parser'] == 'linebreaks':
return parse(''.join(args['story']))
def parse(text):
# A preformatter to convert linebreak to its HTML counterpart
text = re.sub('\\n\\n+','

',text)
text = re.sub('\\n','
',text)
return '
%s
' % text
|
FIXME - write this section
FIXME - write this section
New in Pyblosxom 1.5
The pyblosxom-cmd command allows for plugin-defined commands. This allows your plugin to do maintenance tasks (updating an index, statistics, generating content, ...) and allows the user to schedule command execution through cron or some similar system.
To write a new command, you must:
For example, this adds a command to print command line arguments:
1 2 3 4 5 6 7 | def printargs(command, argv):
print argv
return 0
def cb_commandline(args):
args["printargs"] = (printargs, "prints arguments")
return args
|
Note
The plugin must be in a directory specified by load_plugins in the user’s config.py file.
Executing the command looks like this:
% pyblosxom-cmd printargs --config /path/to/config.py/dir a b c
pyblosxom-cmd version 1.5
a b c


C@N[1][4]
HEY ACM!
Code@Night on Friday! (Yes during Reading Period.) Sponsored by TokBox.
You wonder: what's a TokBox? Welll...
----
The OpenTok API, created by TokBox, makes it dead simple to add face-to-face communication into a site or app experience. Check out the OpenTok Gallery to see partner apps ranging from collaboration tools to gaming.
Interested in developing your own OpenTok powered app? IncuBox is a student developer competition that will award one team the chance to incubate out of TokBox’s San Francisco HQ for 8 weeks during the summer of 2012. Apply now!
----
A real coder from TokBox will be there Friday at 10pm to give a talk and throughout the night to hang out with us! Sweet!
You further wonder: why should I attend this Code@Night? Welll...
* CODE around others!
* STRESS about Dean's Date around others!
* You could learn how to add video chat to your COS 318 file system
* You could add a video chat command to your COS 217 ish shell
* You could start a new COS 429 final project with video chat images
* You could query and parse results from video chatting to add to your COS 402 machine learning algs
* Drink --free-- sodas / energy drinks / water / random other beverages that we feel like buying
* Eat --free-- pizza / snacks / fruit / green beans
* POWER SO MUCH POWER ZOMG
* Sit in comfy chairs
* Learn about TokBox
So...You should come to Code@Night. QED, yo.
FRIDAY 1/13 9PM
SHERRERD HALL, 3rd FLOOR
SPONSORED BY TOKBOX, WHO WILL TALK AT 10
IT'S FUNNNNN


| Home | Trees | Indices | Help |
|---|
|
|
Cosmological distance measures.
Mostly follows David Hogg's pedagogical paper arXiv:astro-ph/9905116v4 .
Distance units are Mpc, time units are seconds.
| Functions | |||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
| Variables | |
__package__ =
|
| Function Details |
'Spatial curvature density' omega_k_0 for a cosmology (if needed). If omega_k_0 is specified, return it. Otherwise return: 1.0 - omega_M_0 - omega_lambda_0 |
Returns the cosmo dictionary with omega_k_0 set. See get_omega_k_0. Note that cosmo is not passed as **cosmo for once. This function modifies the dictionary in place and returns the result. |
The unitless Hubble expansion rate at redshift z. In David Hogg's (arXiv:astro-ph/9905116v4) formalism, this is equivalent to E(z), defined in his eq. 14. Modified (JBJ, 29-Feb-2012) to include scalar w parameter |
The value of the Hubble constant at redshift z. Units are s^-1 In David Hogg's (arXiv:astro-ph/9905116v4) formalism, this is equivalent to H_0 * E(z) (see his eq. 14). |
The value of the Hubble distance at redshift z. Units are Mpc. In David Hogg's (arXiv:astro-ph/9905116v4) formalism, this is equivalent to D_H / E(z) = c / (H_0 E(z)) [see his eq. 14], which appears in the definitions of many other distance measures. |
The derivative of the comoving distance with redshift: dd_c/dz. See equation 15 of David Hogg's arXiv:astro-ph/9905116v4 Units are Mpc. |
The line-of-sight comoving distance (in Mpc) to redshift z. See equation 15 of David Hogg's arXiv:astro-ph/9905116v4 Units are Mpc. Optionally calculate the integral from z0 to z. Returns
Examples>>> import cosmolopy.distance as cd >>> cosmo = {'omega_M_0' : 0.3, 'omega_lambda_0' : 0.7, 'h' : 0.72} >>> cosmo = cd.set_omega_k_0(cosmo) >>> d_co = cd.comoving_distance(6., **cosmo) >>> print "Comoving distance to z=6 is %.1f Mpc" % (d_co) Comoving distance to z=6 is 8017.8 Mpc |
Returns comoving_distance_transverse. Units are Mpc. Examples>>> import cosmolopy.distance as cd >>> cosmo = {'omega_M_0' : 0.3, 'omega_lambda_0' : 0.7, 'h' : 0.72} >>> cosmo = cd.set_omega_k_0(cosmo) >>> d_M = cd.proper_motion_distance(6., **cosmo) >>> print "Transverse comoving distance to z=6 is %.1f Mpc" % (d_M) Transverse comoving distance to z=6 is 8017.8 Mpc |
The transverse comoving distance (in Mpc) to redshift z. This is also called the proper motion distance, D_M. See equation 16 of David Hogg's arXiv:astro-ph/9905116v4 Units are Mpc. This is the distance d_m, such that the comoving distance between two events at the same redshift, but separated on the sky by some angle delta_theta is d_m * delta_theta. Examples>>> import cosmolopy.distance as cd >>> cosmo = {'omega_M_0' : 0.3, 'omega_lambda_0' : 0.7, 'h' : 0.72} >>> cosmo = cd.set_omega_k_0(cosmo) >>> d_M = cd.comoving_distance_transverse(6., **cosmo) >>> print "Transverse comoving distance to z=6 is %.1f Mpc" % (d_M) Transverse comoving distance to z=6 is 8017.8 Mpc |
The angular-diameter distance (Mpc) to redshift z. Optionally find the angular diameter distance between objects at z0 and z (only implemented for omega_k_0 >= 0). See equations 18-19 of David Hogg's arXiv:astro-ph/9905116v4 Units are Mpc. Examples>>> import cosmolopy.distance as cd >>> cosmo = {'omega_M_0' : 0.3, 'omega_lambda_0' : 0.7, 'h' : 0.72} >>> cosmo = cd.set_omega_k_0(cosmo) >>> d_a = cd.angular_diameter_distance(6., **cosmo) >>> print "Angular diameter distance = %.1f Mpc" % (d_a) Angular diameter distance = 1145.4 Mpc |
The luminosity distance to redshift z. Units are Mpc. See, for example, David Hogg's arXiv:astro-ph/9905116v4 |
The differential comoving volume element dV_c/dz/dSolidAngle. Dimensions are volume per unit redshift per unit solid angle. Units are Mpc**3 Steradians^-1. See David Hogg's arXiv:astro-ph/9905116v4, equation 28. Examples>>> import cosmolopy.distance as cd >>> cosmo = {'omega_M_0' : 0.3, 'omega_lambda_0' : 0.7, 'h' : 0.72} >>> cosmo = cd.set_omega_k_0(cosmo) >>> dVc = cd.diff_comoving_volume(6.0, **cosmo) >>> print "dV/dz/dSolidAngle at z=6 is %.3g Mpc**3" % (dVc) dV/dz/dSolidAngle at z=6 is 2.63e+10 Mpc**3 |
The comoving volume out to redshift z. See David Hogg's arXiv:astro-ph/9905116v4, equation 29. Examples>>> import cosmolopy.distance as cd >>> cosmo = {'omega_M_0' : 0.3, 'omega_lambda_0' : 0.7, 'h' : 0.72} >>> cosmo = cd.set_omega_k_0(cosmo) >>> Vc = cd.comoving_volume(6.0, **cosmo) >>> print "Vc = %.3g Mpc**3" % (Vc) Vc = 2.16e+12 Mpc**3 >>> import cosmolopy.distance as cd >>> cosmo = {'omega_M_0' : 0.3, 'omega_lambda_0' : 0.0, 'h' : 0.72} >>> cosmo = cd.set_omega_k_0(cosmo) >>> Vc = cd.comoving_volume(6.0, **cosmo) >>> print "Vc = %.3g Mpc**3" % (Vc) Vc = 1.68e+12 Mpc**3 |
The derivative of the lookback time with redshift: dt_L/dz. See equation 30 of David Hogg's arXiv:astro-ph/9905116v4 Units are seconds. |
The lookback time (in s) to redshift z. See equation 30 of David Hogg's arXiv:astro-ph/9905116v4 Units are s. Optionally calculate the integral from z0 to z. Returns
|
The age of the universe as seen at redshift z. Age at z is lookback time at z'->Infinity minus lookback time at z. See also: lookback_time. Units are s. Examples>>> import cosmolopy.distance as cd >>> import cosmolopy.constants as cc >>> cosmo = {'omega_M_0' : 0.3, 'omega_lambda_0' : 0.7, 'h' : 0.72} >>> cosmo = cd.set_omega_k_0(cosmo) >>> t = cd.age(6.0, **cosmo) >>> print "age at z=6.0 = %.3g Gyr" % (t/cc.Gyr_s) age at z=6.0 = 0.892 Gyr |
The age of the universe assuming a flat cosmology. Units are s. Analytical formula from Peebles, p. 317, eq. 13.2. Examples>>> import cosmolopy.distance as cd >>> import cosmolopy.constants as cc >>> cosmo = {'omega_M_0' : 0.3, 'omega_lambda_0' : 0.7, 'h' : 0.72} >>> cosmo = cd.set_omega_k_0(cosmo) >>> t = cd.age_flat(6.0, **cosmo) >>> print "age at z=6.0 is %.3g Gyr" % (t/cc.Gyr_s) age at z=6.0 is 0.892 Gyr |
Return an interpolation function that will give distance as a funtion of z If return_inverse is True, will also return a function giving z as a function of distance. Inputsfunction -- the distance function to interpolate (can be any callable that takes a redshift argument plus cosmology keywords). k -- spline order ( Returnsdistfunc or distfunc, zfunc Examples>>> import cosmolopy.distance as cd >>> import cosmolopy.constants as cc >>> cosmo = {'omega_M_0' : 0.3, 'omega_lambda_0' : 0.7, 'h' : 0.72} >>> cosmo = cd.set_omega_k_0(cosmo) >>> distfunc, redfunc = cd.quick_distance_function(cd.luminosity_distance, return_inverse=True, **cosmo) >>> d = distfunc(6.3333) >>> z = redfunc(d) >>> "%.1g" % (distfunc(6.3333)/cd.luminosity_distance(6.3333, **cosmo) - 1.0) '-2e-16' >>> "%.1g" % (z/6.3333 - 1.0) '0' |
Return an interpolation function that will give age as a funtion of z Units are s. If return_inverse is True, will also return a function giving z as a function of age. Returnsagefunc or agefunc, redfunc Examples>>> import cosmolopy.distance as cd >>> import cosmolopy.constants as cc >>> cosmo = {'omega_M_0' : 0.3, 'omega_lambda_0' : 0.7, 'h' : 0.72} >>> cosmo = cd.set_omega_k_0(cosmo) >>> agefunc = cd.quick_age_function(**cosmo) >>> t = agefunc(6.0) >>> print "age at z=6.0 is %.3g Gyr" % (t/cc.Gyr_s) age at z=6.0 is 0.892 Gyr |
Return an interpolation function giving z as a funtion of age of the universe. Units of time are s. Returnsredfunc Examples>>> import cosmolopy.distance as cd >>> import cosmolopy.constants as cc >>> cosmo = {'omega_M_0' : 0.3, 'omega_lambda_0' : 0.7, 'h' : 0.72} >>> cosmo = cd.set_omega_k_0(cosmo) >>> redfunc = cd.quick_redshift_age_function(**cosmo) >>> z = redfunc(1.0 * cc.Gyr_s) >>> print "When age=1.0Gyr z=%.2f" % (z) When age=1.0Gyr z=5.49 |
The light travel distance to redshift z. Units are Mpc. Examples>>> import cosmolopy.distance as cd >>> cosmo = {'omega_M_0' : 0.3, 'omega_lambda_0' : 0.7, 'h' : 0.72} >>> cosmo = cd.set_omega_k_0(cosmo) >>> dlookback = cd.light_travel_distance(3.0, 2.0, **cosmo) >>> print "Lookback distance from z=2 to 3 is %.2g Mpc" % (dlookback) Lookback distance from z=2 to 3 is 3.3e+02 Mpc |
The redshift corresponding to a given light travel distance. Units are the same as light_travel_distance (Mpc). Examples>>> import cosmolopy.distance as cd >>> import cosmolopy.constants as cc >>> cosmo = {'omega_M_0' : 0.3, 'omega_lambda_0' : 0.7, 'h' : 0.72} >>> cosmo = cd.set_omega_k_0(cosmo) >>> z = cd.redshift_d_light(10. * cc.c_light_Mpc_Gyr, **cosmo) Optimization terminated successfully. Current function value: 0.000112 Iterations: 26 Function evaluations: 52 >>> print "Redshift for a lookback time of 10Gyr is z=%.3f" % (z) Redshift for a lookback time of 10Gyr is z=2.025 |
| Home | Trees | Indices | Help |
|---|
| Generated by Epydoc 3.0.1 on Tue Mar 27 20:49:14 2012 | http://epydoc.sourceforge.net |


Ask questions or make suggestions about marketing, business development, or anything else relevant. This is the channel to discuss topics with Komodo team.
100 messages
Before 05-Dec-19 12:00 AM
regnarBOT11-Jun-18 12:10 PM
okay, I'll try this tonight hopefully. got to go to class
We need a bot developer to connect to http://riot.im, Discord and Slack that will auto curate all messages from jl777 and a human editor to keep them clean and assign tag.
apart from that, i see only manual way.
haha I'll do my best. but I need to get ready for the day. later
<@U9K42AHQW> I know <@U6ZES59AA> is looking at the website - it is being considered.
if you have information architecture in place for this, that's great! <@U6ZR6LU4F>
<@U4X7GDWT0> I'd love to see you work with Crypto Rich on this as it's a video we could have at the top... can you DM me an email and I'll introduce?
<@U9K42AHQW> i am a humble marketing monkey and do my best
each day I make a sacrifice to the new Gods and the old.
the bot control interface we've got can filter by user i believe, so we can get a daily digest of jl777 stuff
jl777 discussed scaling solutions, privacy, and notary nodes for @KomodoPlatform on @telegram today. Definitely an awesome read, check it out!
https://t.co/kDn1HsIJHS
Give me a follow :)
Tweets out
discord is primary interface the bot dev has focussed. twitter added today. telegram is another channel that is connected but unused. slack works but he's not doing too much work on it.
nice. there's a bunch of stuff on internal docs <@U9LBB4CTG> and i have been c+p from time to time that can be grouped into these collections/vision of the project
jl777 doesn't use twitter. if we have all the public channels cross-connected to discord and @discord-bot filter out all the posts from all public channels and put them into a dedicated channel, an admin user can filter out the informative one, we can perhaps link that channel to the http://komodoplatform.com site using a page
101 Series: #komodo is up and ready to go. Brent and Karim sit down and try to slay this Dragon and see if they can make sense of the #barterdex and #atomicswap procedures. Episode on $KMD is live now. https://t.co/9yUIVVlDoF
hack.summit() is a virtual conference where you can learn from the world’s most renowned programming language creators, open-source contributors, and thought leaders
Johnny Gonzo12-Jun-18 09:32 AM
It seems KMD needs to emphasize the privacy aspect of the coin and network. Under marketed I think in that regard.
Hi @goldenman, already know something about the Komodo fan-art contest?
goldenman16-Jun-18 11:05 AM
Hi Senda. I just posted the result! you are on 3rd place!
Please check my steemit post.
and let me know your KMD address
goldenman16-Jun-18 11:24 AM
@Senda ^
GatewayBOT16-Jun-18 03:24 PM
[matrix] <dragonrider-e:matrix.org> haha, cool
theshark16-Jun-18 05:48 PM
Hey guys! Question for the Komodo team! I'm on the team over at CCI, and we wanted to know if you all would be interested in a video interview to get your project out to about 450k investors
I was asked by one of your admins in your Telegram group to reach out to you all
KomodoWorld16-Jun-18 06:10 PM
I'm just a random guy but don't know what CCI is, do you have a link?
GatewayBOT16-Jun-18 07:17 PM
[slack] <PTYX> Can to show us a link to your website please
Cryptocurrency Investing provides current cryptocurrency prices and the latest cryptocurrency news, ethereum, altcoins, blockchain tech, ICO's, and everything cryptocurrency in one place.
Welcome to Cryptocurrency Investing!
This group is designed for intelligent discussion on blockchain technology and cryptocurrency investments. The intention of this group is to be a community forum...
Deleted User17-Jun-18 01:03 PM
when will the roadmap be announced in 2H?
and i'm also curious about komodo 2.0
GatewayBOT17-Jun-18 11:09 PM
[slack] <Regnar> just a thought, we should have a page on dexstats that shows a list of all coins that are built on Komodo and/or using dPoW. Many of the dICO coins would be on it but GameCredits, Verus, and Kreds too. This page could be linked to from the main http://Komodoplatform.com. or could even be a page on http://Komodoplatform.com that shows the coins using dPoW for 51% protection, as well as a link to whatever announcement page they have explaining their reasons for selecting KMD.
[slack] <Regnar> and on the dPoW/Komodo Security Services/51% protection page we could have some options for how other projects could get these features, either by integrating dPoW like Gamecredits (slower) or by migrating to Komodo (preferred)
[slack] <Regnar> thoughts?
[matrix] <dragonrider-e:matrix.org> James already asked to wait on this, as i remember.
[matrix] <dragonrider-e:matrix.org> I mean, it's gonna happen, just not now.
[slack] <Regnar> okay.
[slack] <Regnar> yea I know the whole adding dpow to existing coins is a difficult process
[matrix] <dragonrider-e:matrix.org> Once there's experience, it will become easier and easier.
[slack] <Regnar> and migration is preferred. I think advertising it would be effective.
[matrix] <dragonrider-e:matrix.org> I agree.
[slack] <Regnar> in due time haha
[slack] <Regnar> also this
[slack] <Regnar>
[slack] <Regnar> not sure who controls the dexstats page, I think it's @SHossain just a small spelling error
GatewayBOT18-Jun-18 01:42 AM
[slack] <xrobesx> @CHMEX
GatewayBOT18-Jun-18 03:19 AM
[slack] <CHMEX> Thanks. Changed now
GatewayBOT18-Jun-18 06:46 AM
[slack] <CrypToon> I liked the assets page btw @CHMEX are there any plans to add more assets to it like DEX?
[slack] <CrypToon> (I might have already asked this question, forgive me if I did)
GatewayBOT18-Jun-18 07:01 AM
[slack] <CHMEX> Yes it's something I would like to complete soon also for crypto currently it's a bit tricky to get the balance for notarizations as the explorers to not handle the uxtos properly ( my guess )
for Dex the initial holdings need to be subtracted. There is a meeting this week in neuchatel I hope we have some fruitful conversations there
Can the marketing team make a push. And request the r/komodo subreddit. It's completely dead and I think we can convince the reddit mods to give it to us.
BREAKING! @KomodoPlatform launches @dev_sec group for providing a wide range of advanced security testing to every blockchain project. It comprises engineers, developers, security experts & exploit researchers in order to be "a step ahead of the bad guys": https://t.co/eAd...
Eight cryptocurrencies are expanding their reach with new exchange listings this month. Here’s the rundown. IOTA and Komodo on BitPanda BitPanda just added IOTA (IOTA) and Komodo (KMD) to its roster. Bitpanda is the biggest retail exchange in Europe, allowing customers to ...
jorian19-Jun-18 11:50 AM
@KomodoWorld i don't think DSEC is launched by the KMD platform(edited)
KomodoWorld19-Jun-18 11:53 AM
my impression is that it's a closely related thing
PTYX19-Jun-18 11:57 AM
Dsec is launched by ca333(edited)
KomodoWorld19-Jun-18 12:01 PM
how could I phrase it better? I can add it's a decentralized group, closely collaborating with but independent
done
jorian19-Jun-18 12:05 PM
it's independent but i guess dSEC will be close to KMD platform
PTYX19-Jun-18 12:27 PM
Yes it will.
GatewayBOT19-Jun-18 04:31 PM
<system> file Image from iOS.jpg too big to download (6965036 > allowed size: 1000000)
Public blockchain versus private blockchain : Projects presentation:
∟ FundRequest : Tim Dierckxsens
∟ Wibson : Mat Travizano
∟Komodo : Chris van Maarseveen
∟ KYC-Chain : Edmund Lowell
[slack] <CrypToon> @
<system> file Image from iOS.jpg too big to download (6392217 > allowed size: 1000000)


In this page, you will find the commonly used syntax and how to’s that is specific to Tcl programming language. If you know what Tcl is, but wanted to quickly refer to Tcl syntax, then you might find this page useful. I will keep on updating this article. So, kindly bookmark this page if you find it useful :)
Standard IOcode
1
2
3
4
5 | # get user input
set a [gets stdin]
# print output to screen
puts $a
|
Math operationscode
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 | # basic math operations
set add [expr $a + $b]
set sub [expr $a - $b]
set mul [expr $a * $b]
set div [expr $a / $b]
set mod [expr $a % $b]
# some more math operations
puts "[expr sqrt(4)]"
puts "[expr sin(4)]"
puts "[expr cos(4)]"
puts "[expr tan(4)]"
puts "[expr sinh(4)]"
puts "[expr cosh(4)]"
puts "[expr tanh(4)]"
puts "[expr log(1)]"
puts "[expr ceil(4.6)]"
puts "[expr floor(4.6)]"
puts "[expr srand(4.6)]"
|
Looping statementscode
1
2
3
4
5
6
7
8
9
10
11 | # for loop
for {set i 0} {$i < 50} {incr i} {
puts $i
}
# while loop
set i 0
while {$i < 50} {
puts $i
incr i
}
|
Conditional statementscode
1
2
3
4
5
6
7
8 | set i 50
if {$i > 100} {
puts "Ferrari"
} elseif {$i > 50} {
puts "Mclaren"
} else {
puts "Pikachu"
}
|
Logical operationscode
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 | set i "Batman"
set j 2
# logical AND & Logical OR
if {$i == "Ironman" && $j == 1} {
puts "I love Ironman"
} elseif {$i == "Batman" || $j == 2} {
puts "I love Batman"
}
# boolean
set a true
if $a {
puts "Yes! It is true"
}
|
Switchcode
1
2
3
4
5
6
7
8
9
10
11
12 | set x 30
# the best syntax to use "switch" in Tcl
# although there are multiple ways
# such as writing in a single-line
switch $x {
"10" {puts "this is 10"}
"20" {puts "this is 20"}
"default" {puts "this is default"}
}
# prints "this is default"
|
Listscode
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38 | # Three ways to create a list
set l {"Dhoni" "Kohli" "Dravid"}
set l [list Dhoni Kohli Dravid]
set l [split "Dhoni Kohli Dravid"]
# length of a list
puts "[llength $l]"
# get the item at a specific index
puts "[lindex $l 2]"
# retrieve several items within a range
puts "[lrange $l 0 2]"
# concat two lists
set l2 {Ganguly Sehwag}
set l [concat $l $l2]
# append an item to list
lappend l Rohit
# insert an item to a particular index
set l [linsert $l 2 "Dhawan"]
# replacing an item in the list
# Note that we need to give here a range
set l [lreplace $l 2 3 "Laxman"]
# search for an item in the list
# returns index of the item if there is match
# else returns -1
set check [lsearch $l "Dhoni"]
# sorting a list (increasing order)
puts "[lsort $l]"
# sorting a list (decreasing order)
puts "[lsort -decreasing $l]"
|
Dictionariescode
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 | # create a dictionary with key-value pair
set d [dict create 1 Dhoni 2 Kohli 3 Rohit]
# get the unique keys in the dictionary
set keys [dict keys $d]
# loop over each key to get its corresponding value
foreach key $keys {
# get the value of a key
set value [dict get $d $key]
puts "$key -- $value"
}
# prints the size of dictionary
puts "[dict size $d]"
# prints the values in the dictionary
puts "[dict values $d]"
|
Stringscode
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35 | set s "/home/gogul/software/sublime/packages"
# get the length of the string
puts "[string length $s]"
# get the character at a specified index in the string
puts "[string index $s 2]"
# get the characters within a range in the string (sub-string)
puts "[string range $s 0 10]"
# split the string and make it a list
# observe the delimiter here
set l [split $s /]
# compare two strings (not numerically)
# -1 --> if string1 is less than string2
# 0 --> if string1 is equal to string2
# 1 --> if string1 is greater than string2
set s1 "Dhoni"
set s2 "Kohli"
puts "[string compare $s1 $s2]"
# match a pattern in the string
puts "[string match "*gogul*" $s]"
# convert all letters to upper-case
puts "[string toupper $s]"
# convert all letters to lower-case
puts "[string tolower $s]"
# convert all letters to title
# first letter upper-case followed by lower-case
puts "[string totitle $s]"
|
Regular expressionscode
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 | set s "This is a string with a number 123456789"
# regex to match a number
set result [regexp {\d.*\d} $s match]
# returns 1 if there is a match
puts $result
# returns the matched string
puts $match
# search for a pattern and if present,
# substitute it with a string
# and return the result
set s "Dhoni is an awesome player in cricket."
regsub Dhoni $s Kohli result
# prints Kohli is an awesome player in cricket.
puts $result
|
Procscode
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 | # a simple proc with two arguments and a return statement
proc addition {a b} {
set c [expr $a + $b]
return $c
}
puts "[addition 5 4]"
# proc with multiple arguments
# "args" as the third argument holds all additional values supplied
proc more_args {a b args} {
puts $a
puts $b
puts $args
}
# prints
# 5
# 6
# 90 60 10
more_args 5 6 90 60 10
|
File handlingcode
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 | # opens a file to write
set fp [open "sample_text_file" w]
# writes data to the file
puts $fp "Hello World"
# close the file after writing (else data won't be saved)
close $fp
# open a file to read
set fp [open "sample_text_file" r]
# read the content of the file
set fp_data [read $fp]
# split by newline
set lines [split $fp_data "\n"]
# loop through each line in the file
foreach line $lines {
# do some processing
}
|
Utilscode
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 | # execute shell commands inside Tcl
# prints the present working directory
exec pwd
# prints the current datetime
exec date
# creates a new directory in the present working directory
exec mkdir new_folder
# save the pwd in a variable
set p [pwd]
# change directory
cd another_folder
|
Otherscode
1
2
3
4 | # execute a file within a file
# so that procs/variables used in another file
# are available in the current file
source filename
|
In case if you found something useful to add to this article or you found a bug in the code or would like to improve some points mentioned, feel free to write it down in the comments. Hope you found something useful here.
Happy learning!


|
µEvLoop
A fast and lightweight event loop aimed at embedded platforms in C99.
|
Contains definitions for promise stores, promises and functions to manipulate them. More...
#include "uevloop/config.h"
#include "uevloop/utils/closure.h"
#include "uevloop/utils/object-pool.h"
Go to the source code of this file.
Data Structures | |
| struct | uel_promise_segment_t |
| Defines a single synchronous operation to be invoked when the promise is either resolved or rejected. More... | |
| struct | uel_promise_t |
| A promise is association of an asynchronous operation to the possible execution paths that follow its resolution. It is also a holder for the value it was settled with. More... | |
| struct | uel_promise_store_t |
| An issuer of promises. Contains references to pools for promises and segments. More... | |
Typedefs | |
| typedef enum uel_promise_state | uel_promise_state_t |
Alias to the uel_promise_state enum. | |
Enumerations | |
| enum | uel_promise_state { UEL_PROMISE_PENDING, UEL_PROMISE_RESOLVED, UEL_PROMISE_REJECTED } |
| Defines the possible states for a prommise. More... | |
Functions | |
| uel_promise_store_t | uel_promise_store_create (uel_objpool_t *promise_pool, uel_objpool_t *segment_pool) |
| Creates a new promise store from the promise and segment pools. More... | |
| uel_promise_t * | uel_promise_create (uel_promise_store_t *store, uel_closure_t closure) |
| Acquires a new promise from the supplied store and binds it to the asynchronous operation started by the supplied closure. The closure is invoked immediately. More... | |
| void | uel_promise_destroy (uel_promise_t *promise) |
| Destroys a promise and all of its segments. Settling this promise afterwards yields undefined behaviour. More... | |
| void | uel_promise_then (uel_promise_t *promise, uel_closure_t resolve) |
| Adds a new synchronous segment to the promise. It will be invoked upon promise resolution. In case of rejection, this segment will be ignored. More... | |
| void | uel_promise_catch (uel_promise_t *promise, uel_closure_t reject) |
| Adds a new synchronous segment to the promise. It will be invoked upon promise rejection. In case of resolution, this segment will be ignored. More... | |
| void | uel_promise_always (uel_promise_t *promise, uel_closure_t always) |
| Adds a new synchronous segment to the promise. The same closure will be invoked on promise settling regardless of the settled state. More... | |
| void | uel_promise_after (uel_promise_t *promise, uel_closure_t resolve, uel_closure_t reject) |
| Adds a new synchronous segment to the promise. Either of its closures will be invoked, depending on the settled state of the promise. More... | |
| void | uel_promise_resolve (uel_promise_t *promise, void *value) |
Settles a promise as resolved and, synchronously, invokes the resolve closures of each segment in the order they were registered. More... | |
| void | uel_promise_reject (uel_promise_t *promise, void *value) |
Settles a promise as rejected and, synchronously, invokes the reject closures of each segment in the order they were registered. More... | |
| void | uel_promise_resettle (uel_promise_t *promise, uel_promise_state_t state, void *value) |
Resettles a promise as the supplied state. Unlike uel_promise_resolve() and uel_promise_reject() , does not invoke the synchronous segments. More... | |
| uel_closure_t | uel_promise_resolver (uel_promise_t *promise) |
| Creates a closure bound to a promise. When the closure is invoked with some parameter, the promise is resolved with this parameter as value. More... | |
| uel_closure_t | uel_promise_rejecter (uel_promise_t *promise) |
| Creates a closure bound to a promise. When the closure is invoked with some parameter, the promise is rejected with this parameter as error. More... | |
| uel_closure_t | uel_promise_destroyer (uel_promise_t *promise) |
| Creates a closure bound to a promise. When the closure is invoked, the promise is destroyed. Any parameters passed to the closure are ignored. More... | |
Contains definitions for promise stores, promises and functions to manipulate them.
Promises are structures that associate asynchronous operations to synchronous processing of the values produces by them, allowing async data pipelines to be built.
| enum uel_promise_state |
| void uel_promise_after | ( | uel_promise_t * | promise, |
| uel_closure_t | resolve, | ||
| uel_closure_t | reject | ||
| ) |
Adds a new synchronous segment to the promise. Either of its closures will be invoked, depending on the settled state of the promise.
| promise | The promise to attach the segment to |
| resolve | The closure to be invoked when the promise is resolved |
| reject | The closure to be invoked when the promise is rejected |
| void uel_promise_always | ( | uel_promise_t * | promise, |
| uel_closure_t | always | ||
| ) |
Adds a new synchronous segment to the promise. The same closure will be invoked on promise settling regardless of the settled state.
| promise | The promise to attach the segment to |
| always | The closure to be invoked when the promise is settled |
| void uel_promise_catch | ( | uel_promise_t * | promise, |
| uel_closure_t | reject | ||
| ) |
Adds a new synchronous segment to the promise. It will be invoked upon promise rejection. In case of resolution, this segment will be ignored.
| promise | The promise to attach the segment to |
| reject | The closure to be invoked when the promise is rejected |
| uel_promise_t* uel_promise_create | ( | uel_promise_store_t * | store, |
| uel_closure_t | closure | ||
| ) |
Acquires a new promise from the supplied store and binds it to the asynchronous operation started by the supplied closure. The closure is invoked immediately.
| store | The store from where to acquire promises and segments |
| closure | The closure that initiates the asynchronous operation |
| void uel_promise_destroy | ( | uel_promise_t * | promise | ) |
Destroys a promise and all of its segments. Settling this promise afterwards yields undefined behaviour.
| promise | The promise to be destroyed |
| uel_closure_t uel_promise_destroyer | ( | uel_promise_t * | promise | ) |
Creates a closure bound to a promise. When the closure is invoked, the promise is destroyed. Any parameters passed to the closure are ignored.
| promise | The promise to be destroyed |
| void uel_promise_reject | ( | uel_promise_t * | promise, |
| void * | value | ||
| ) |
Settles a promise as rejected and, synchronously, invokes the reject
closures of each segment in the order they were registered.
If a segment returns a non-NULL pointer, it is cast to a promise pointer and the original promise awaits until the returned promise is settled.
| promise | The promise to be rejected |
| value | The value to reject the promise with |
| uel_closure_t uel_promise_rejecter | ( | uel_promise_t * | promise | ) |
Creates a closure bound to a promise. When the closure is invoked with some parameter, the promise is rejected with this parameter as error.
| promise | The promise to be rejected |
| void uel_promise_resettle | ( | uel_promise_t * | promise, |
| uel_promise_state_t | state, | ||
| void * | value | ||
| ) |
Resettles a promise as the supplied state. Unlike uel_promise_resolve()
and uel_promise_reject()
, does not invoke the synchronous segments.
This function should be used to switch execution paths during synchronous processing of segments as to signal that an error was raised or rescued by a particular segment. If the promise is settled as pending, the synchronous processing phase is interrupted.
| promise | The promise to be resettled |
| state | The new promise state |
| value | The new promise value |
| void uel_promise_resolve | ( | uel_promise_t * | promise, |
| void * | value | ||
| ) |
Settles a promise as resolved and, synchronously, invokes the resolve
closures of each segment in the order they were registered.
If a segment returns a non-NULL pointer, it is cast to a promise pointer and the original promise awaits until the returned promise is settled.
| promise | The promise to be resolved |
| value | The value to resolve the promise with |
| uel_closure_t uel_promise_resolver | ( | uel_promise_t * | promise | ) |
Creates a closure bound to a promise. When the closure is invoked with some parameter, the promise is resolved with this parameter as value.
| promise | The promise to be resolved |
| uel_promise_store_t uel_promise_store_create | ( | uel_objpool_t * | promise_pool, |
| uel_objpool_t * | segment_pool | ||
| ) |
Creates a new promise store from the promise and segment pools.
| promise_pool | The uel_objpool_t that holds promises |
| segment_pool | The uel_objpool_t that holds segments |
| void uel_promise_then | ( | uel_promise_t * | promise, |
| uel_closure_t | resolve | ||
| ) |
Adds a new synchronous segment to the promise. It will be invoked upon promise resolution. In case of rejection, this segment will be ignored.
| promise | The promise to attach the segment to |
| resolve | The closure to be invoked when the promise is resolved |


--- layout: post title: Death plague date: '2016-07-04T08:29:45+02:00' categories: - Atoleiros Battle picture_url: https://film-Storyboards.tumblr.com/post/146895025231 ---


Many Australians with chronic diseases have trouble remembering to take their medications on time or deviate from their doctor’s orders. This is often because it can get very hard to keep track of multiple medication regimens, and for chronic diseases it can be tempting to stop taking medications when symptoms seem to go away. Although apps exist to help patients with these issues, they have problems with maintaining user engagement in the long-term.
MediRoo is a mobile application that helps users keep track of their medications with regular reminders, motivating feedback, and a simple interface. The app targets users with multiple daily prescriptions, where it can be difficult to maintain a constant schedule with pills that may be important to health. The app is designed with older patients in mind, who may be less technically inclined and are more easily intimidated by screens with too many points of interaction. This design philosophy is evidenced through the process of adding medications, the notifications the user receives as reminders, the tracking of symptoms and the reporting of the patient's “performance” (in taking pills on time) over time.
The app allows patients to select all the medications they are taking, after which it will remind them to take their medication at the appropriate times, also noting how they are feeling on each occasion. For example, suppose an elderly patient has to keep up with four different prescriptions at varying schedules in the same day. With MediRoo, the patient is able to follow their prescribed medication regimen just by responding to a smartphone’s alerts, resulting in a much lower cognitive load and fewer mistakes. This is just one example of the benefits to users of this app: they would be more likely to experience the benefits of medication when taking it according to the doctor’s instructions, and by using the app they will be more willing and able to stick to their prescribed regimens.
Check out all the features of MediRoo!
Medications will be easily managed
You do not have to remember when to take your pills
You can record you symptoms as you go
Can monitor your health status more easily


{% load static %}
Electrical Engineer at GE Power ConversionFocused on embedded systems, controls, and software.


This setting provides detailed control over the warnings about
supported extensions to the Fortran 77 Standard that were not adopted
as part of the Fortran 90 Standard. Note that ftnchek does not
support the full Fortran 90 language. However, it does support some
common extensions to Fortran 77 that were prevalent before Fortran 90
was defined. Some of these extensions became part of the Fortran 90
Standard, but others did not. The -f90 setting warns only
about the latter. That is, this flag covers things that are neither legal
Fortran 77 nor legal Fortran 90. Therefore, the warnings controlled
by this flag are basically a subset of the warnings controlled by
-f77. There are a few cases, described below, where the
circumstances in which the warning is given are slightly different for
the two flags.
The list
consists of keywords separated by commas or colons.
There are three special keywords: all to turn on all the
warnings about nonstandard extensions, none to turn them all
off, and help to print the list of all the keywords with a brief
explanation of each.
If list is omitted, -f90 is equivalent to
-f90=all, and -nof90 is equivalent to
-f90=none.
The following keywords have identical meanings for -f90 as for
-f77. The reader is referred to the explanations under -f77.
| accept-type | double-complex | param-noparen
|
| backslash | format-dollarsign | pointer
|
| byte | format-edit-descr | quad-constant
|
| cpp | function-noparen | type-size
|
| d-comment | name-dollarsign | variable-format
|
| dec-tab | param-implicit-type | vms-io
|
The keywords which differ somewhat from the corresponding
-f77 keywords are as follows.
- continuation:
-
The limit on the number of continuation lines for a statement in
fixed source form is the
same, namely 19, in Fortran 90 as in Fortran 77. For free
source form the limit is 39 continuation lines, and a line containing
a continuation mark cannot be otherwise empty or contain only a comment.
- intrinsic:
-
This is the same as for -f77 except for the intrinsic
functions defined in MIL-STD 1753, which are all included in Fortran
90, and so are not warned about. (See -intrinsic for a list.)
- io-keywords:
-
This is the same as for -f77 except that no warnings are given
for the I/O keywords that are standard in Fortran 90.
- long-line:
-
Although the Fortran 90 Standard allows lines longer than 72
characters in free source form, this restriction still applies to fixed
source form. In free source form the line length limit is 132 characters,
and unlike fixed form, ftnchek does not allow this limit to
be increased.
- mixed-expr:
-
This is the same as for -f77 except for expressions mixing
extended precision real with complex data types, which are permitted
in Fortran 90.
- statement-order:
-
This is similar to the corresponding -f77 warning, but applies
the somewhat looser restrictions on statement order of the
Fortran 90 Standard. In particular, Fortran 90 allows DATA
statements and statement-function definitions to be intermixed with
specification statements.
- typeless-constant:
-
In Fortran 90, binary, octal, and hexadecimal constants of the form
B'ddd', O'ddd', and Z'ddd', respectively, are
permitted. Here 'ddd' represents a string of digits.
ftnchek recognizes these forms, as well as a variant of the form
X'ddd' for a
hexadecimal constant, and other variants in which the base indicator
B, O, Z, or X
follows the digit string. These variants were not adopted in
Fortran 90, so only they are warned about when this flag is turned on.
See also: -f77, -f95, -portability,
-pretty, -style, -wordsize.


Upcoming Events
Join us on this coming month, we discuss the various threats our environment faces as we also think of possible solutions.
Read More
Up next is about mitigating the impacts of human activities that pose risk to the environment by learning how to recycle some of the products we use as humans.
Read More
Plant plant and plant. It is very essential for humans to be surrounded by trees. Their importants are immeasurable.
Join us on this event as we educate on the important of planting more trees at this very moment as more and more tress are cut daily.
 There's a need for us to protect our trees.
This occasion is aimed at enlightening us on the importance of saving the trees that we have as we continue to plant more.
Read More
Previous Events
Climate change is an imminent threat to our livelihoods. This all starts from lack of awareness of the impact of our activities to our environment.
This events aims at highligting some of the environmental issues we are experiencing.
View Event
Why should I recycle? Come you get the answer.
View Event
Tree is life. Come we enlighten you on its immeasurable benefits.
View Event
Yes, you are the solution. Be part of the solution to the environmental polution. Come we share the various ways of making our environment clean.
View Event


Its data and content are 100% secure. Please check back soon.
If you own this site, please call customer support at<PHONE_NUMBER>.


Skip to main content
Study
Research
Business
Alumni
News
Engagement
Search Warwick
Search
Parent site name
Current site name
{% include divider.html %}
Your page title
Your page content goes here. Use layouts if desired


Next you must be a member of a project. You may either create your own project or you may request to join another project.


This inspection is based on the following paragraph from The LaTeX Companion (2nd edition, page 23):
If you try to advise TeX on how to split the heading over a few lines using the '~' symbol so the '\\' command, then side effects may result when formatting the table of contents or generating the running head. In this case the simplest solution is to repeat the heading text without the specific markup in the optional parameter of the sectioning command.


| Description | This allows developers to add additional class names to the container <div>, useful for making override styles. |
|---|---|
| Default | "default" |
| Description | This can be set to any of the presetOptions to quickly set some common configurations. This will also add a class with the below preset. |
|---|---|
| Type | string |
| Default | "" |
| Description | Turns the gallery into a carousel module where there are slides on both sides. |
|---|---|
| Type | boolean |
| Default | 0 |
| Description | How many slides are visible on each side, needed for prefetch logic and understanding when to pop the last slide to the front, and vice versa. |
|---|---|
| Type | int |
| Default | 2 |
| Description | How long all transition animations take. |
|---|---|
| Type | int |
| Default | 300 |
| Description | The max width and height of the photos inside of the gallery. We dynamically resize to these. Future: Auto flags depending on the screen real estate! |
|---|---|
| Type | int, int |
| Default | 450, 325 |
| Description | The max width and height of generated thumbs. |
|---|---|
| Type | int, int |
| Default | 74, 74 |
| Description | If supplied, render a sponsorship advertisement |
|---|---|
| Type | string |
| Default |
| Description | The sponsorship width and height. |
|---|---|
| Type | int, int |
| Default | 215, 35 |
| Description | If supplied render an advertisement in fullscreen mode. |
|---|---|
| Type | string |
| Default |
| Description | Width and height of rendered fullscreen advertisement. |
|---|---|
| Type | int, int |
| Default | 300, 250 |
| Description | If supplied render a sponsorship advertisement in fullscreen mode. |
|---|---|
| Type | string |
| Default |
| Description | Width and height of rendered fullscreen sponsorship advertisement. |
|---|---|
| Type | int, int |
| Default | 215, 35 |
| Description | How many thumbs to display, we don't quite do anything with this yet, may be useful later for showing an initial thumb set, or controlling how many per thumbnail pane. |
|---|---|
| Type | int |
| Default | 999 |
| Description | Inserts thumbnails immediately after the gallery <div>. False inserts before. |
|---|---|
| Type | boolean |
| Default | true |
| Description | The active photo index on initialization. |
|---|---|
| Type | int |
| Default | 1 |
| Description | The <div> ID containing the AJAX ad to refresh. This is tied to the gallery slides. |
|---|---|
| Type | string |
| Default | "" |
| Description | The refresh ratio. Example: 3 means refresh the ad every 1 in 3 clicks. |
|---|---|
| Type | int |
| Default | 9 |
| Description | This controls whether we show the thumbnails by default instead of the gallery view. |
|---|---|
| Type | boolean |
| Default | false |
| Description | Controls the rendering of the "Show Thumbnails" button. |
|---|---|
| Type | boolean |
| Default | true |
| Description | Inserts the "Show Thumbnails" button before the gallery in the DOM if true, after if false. |
|---|---|
| Type | boolean |
| Default | true |
| Description | Whether or not to show the name of the gallery. |
|---|---|
| Type | boolean |
| Default | true |
| Description | Whether or not to show the description of the gallery. |
|---|---|
| Type | boolean |
| Default | false |
| Description | Whether or not to show the description after. |
|---|---|
| Type | boolean |
| Default | false |
| Description | Whehther or not to show the "Next" and "Back" buttons |
|---|---|
| Type | boolean |
| Default | true |
| Description | If true, insert the controls inside the gallery <div>. |
|---|---|
| Type | boolean |
| Default | false |
| Description | If controlsInside is true, this inserts the controls before (prepends) the photos list in the gallery <div> when true and inserts the controls after (appends) when false. If controlsInside is false, this inserts the controls after (appends) the gallery <div> when true and before (prepends) the controls when false. |
|---|---|
| Type | boolean |
| Default | true |
| Description | Show the fullscreen button. |
|---|---|
| Type | boolean |
| Default | true |
| Description | Shows the status indicator. |
|---|---|
| Type | boolean |
| Default | true |
| Description | Shows the captions for the photos. By default this is a standard fade-in/out. |
|---|---|
| Type | boolean |
| Default | true |
| Description | Inserts the controls inside the gallery <div> when true and outside when false. |
|---|---|
| Type | boolean |
| Default | true |
| Description | Shows the credit box. |
|---|---|
| Type | boolean |
| Default | true |
| Description | Shows the credits inside this gallery UI element. | |
|---|---|---|
| Default | "$captions" | |
| Type | string | |
| Available values |
|
| Description | True initializes Comscore, Data Layer and Omniture tracking. Node: this should be handled automatically in the future. |
|---|---|
| Type | boolean |
| Default | true |
| Description | Appends credit within the "creditInside" container if true and prepends the credit if false. |
|---|---|
| Type | boolean |
| Default | false |
| Description | ImageMagick quality setting. |
|---|---|
| Type | int |
| Default | 85 |
| Available values | Range: 0-100. 0 is lowest quality and 100 is highest quality. |
| Description | An object containing fullscreen display configurations. |
|---|---|
| Type | object |
| Default | { photoWidth:559, photoHeight:487, preset:"carousel", carouselSiblings:3 } |
| Description | Object containing various output templates that developers can override. |
|---|---|
| Type | object |
| Default | { status:"{{active}} of {{total}}", credit:"Photo: {{credit}}", fullscreen:"Fullscreen", thumbnails:"Thumbnails", next: "Next", back: "Back" } |
| Available template values |
|