User Tools

Site Tools


en:cycle_and_function

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
en:cycle_and_function [2013/11/13 04:09]
127.0.0.1 external edit
en:cycle_and_function [2017/10/11 20:36] (current)
Line 1: Line 1:
 ====== Creating a loop and function ====== ====== Creating a loop and function ======
 +FIXME
 +
 How to create a loop, which will repeat given action x-times, and how to define the function will be demonstrated on creating the script for //random walk//. How to create a loop, which will repeat given action x-times, and how to define the function will be demonstrated on creating the script for //random walk//.
  
Line 28: Line 30:
 </​code>​ </​code>​
  
-will randomly select one value from the vector, containing numbers ''​-1''​ and ''​1'',​ in this case value ''​-1''​. You just made the first step to the right.+will randomly select one value from the vector, containing numbers ''​-1'' ​ and ''​1'',​ in this case value ''​-1''​. You just made the first step to the right.
  
 Vector ''​steps.rw''​ contains only zeroes: Vector ''​steps.rw''​ contains only zeroes:
Line 44: Line 46:
 </​code>​ </​code>​
  
-You may have realized that in function ''​sample'',​ there are no names of arguments (''​x''​ and ''​size''​) - they are not needed, until you write the values for arguments in the defined order (what is this order you can check in the help to the function ''​sample'',​ which you call typing ''?​sample''​).+You may have realized that in function ''​sample'',​ there are no names of arguments (''​x'' ​ and ''​size''​) - they are not needed, until you write the values for arguments in the defined order (what is this order you can check in the help to the function ''​sample'',​ which you call typing ''?​sample''​).
  
 Further steps can be defined in the following way: Further steps can be defined in the following way:
Line 87: Line 89:
 </​code>​ </​code>​
  
-The figure is not here, because for ear run the figure looks different. Argument ''​x''​ in the function ''​plot''​ contains values you want to draw. Theoretically,​ the arguments should be two, ''​x''​ and ''​y'',​ i.e. the values for x and y axis; if the ''​y''​ argument is missing, the function proceeds as following: the values of ''​x''​ argument are drawn on vertical axis, and horizontal axis is represented by the order of values in the vector.+The figure is not here, because for each run the figure looks different. Argument ''​x''​ in the function ''​plot''​ contains values you want to draw. Theoretically,​ the arguments should be two, ''​x'' ​ and ''​y'',​ i.e. the values for x and y axis; if the ''​y''​ argument is missing, the function proceeds as following: the values of ''​x''​ argument are drawn on vertical axis, and horizontal axis is represented by the order of values in the vector.
  
 FIXME FIXME
en/cycle_and_function.1384286998.txt.gz · Last modified: 2017/10/11 20:36 (external edit)