I'm going to tease you all with something I've been working on.  
The Premise Language REPL.


Today we'll look at two language intrinsics and a user defined function.
(pick  n  sequence )forms a sequence of n arbitrary items

(random number1
number2 ) chooses
a number within a range

The pick intrinsic selects n arbitrary items from an existing sequence.
The random intrinsic selects a random number within a range.  
Allen Newell and Herbert Simon thought the chunk was a very significant 
number:7 +/- 2 items. To honor their discovery, we can write a function called 
Chunk which takes a sequence and returns a random chunk of it. 

function  chunk {?list}  (pick (+ 7 (random -2 2)) ?list)end
.: chunk

So we pass in a list, and receive a random chunk of it.  
Here are a few examples:
(put {a b c d e f g h i j k l m n o p q r s t u v w x y z} ?alphabet)
.:  {a b c d e f g h i j k l m n o p q r s t u v w x y z} 
(chunk ?alphabet)
.: {c m f h l x}
(chunk ?alphabet)
.: {k h a b f}
(chunk ?alphabet)
.: {w k g s y b l}
(chunk (range 1 to 2000)) 
.: {331 230 291 1017 1530 504 109 280}
(chunk (range 1 to 2000)) 
.: {1313 491 1559 1076 1670}

And there you have it.
Voila.




                                          


-------------------------------------------
AGI
Archives: https://www.listbox.com/member/archive/303/=now
RSS Feed: https://www.listbox.com/member/archive/rss/303/21088071-f452e424
Modify Your Subscription: 
https://www.listbox.com/member/?member_id=21088071&id_secret=21088071-58d57657
Powered by Listbox: http://www.listbox.com

Reply via email to