Another update from ingydotnet^djgoku

This commit is contained in:
Ingy döt Net 2015-11-18 06:14:39 +00:00
parent 91df62d461
commit 948b86eafa
7604 changed files with 108452 additions and 22726 deletions

View file

@ -0,0 +1,16 @@
@echo off
setlocal enabledelayedexpansion
::Initializing the pseudo-array...
set "pseudo=Alpha Beta Gamma Delta Epsilon"
set cnt=0 & for %%P in (!pseudo!) do (
set /a cnt+=1
set "pseudo[!cnt!]=%%P"
)
::Do the random thing...
set /a rndInt=%random% %% cnt +1
::Print the element corresponding to rndint...
echo.!pseudo[%rndInt%]!
pause
exit /b

View file

@ -1,11 +1,12 @@
defmodule Random do
def init() do
:random.seed(:erlang.now())
def init do
:random.seed(:erlang.now)
end
def pick_element(list) do
Enum.at(list, :random.uniform(Enum.count(list)) - 1)
Enum.at(list, :random.uniform(length(list)) - 1)
end
end
Random.init()
IO.puts Random.pick_element(1..20)
Random.init
list = Enum.to_list(1..20)
IO.puts Random.pick_element(list)

View file

@ -0,0 +1,11 @@
program pick_random
implicit none
integer :: i
integer :: a(10) = (/ (i, i = 1, 10) /)
real :: r
call random_seed
call random_number(r)
write(*,*) a(int(r*size(a)) + 1)
end program

View file

@ -0,0 +1,2 @@
(define (pick-random-element R)
(nth (rand (length R)) R))

View file

@ -0,0 +1,12 @@
Define.i
OpenConsole()
a$="One" +#TAB$+ "Two" +#TAB$+ "Three" +#TAB$+ "Four" +#TAB$+ "Five" +#TAB$+
"Six" +#TAB$+ "Seven"+#TAB$+ "Eight" +#TAB$+ "Nine" +#TAB$+ "Ten" +#TAB$
Print("Source list: "+#TAB$+a$+#CRLF$+"Random list: "+#TAB$)
For i=1 To CountString(a$,#TAB$)
Print(StringField(a$,Random(CountString(a$,#TAB$),1),#TAB$)+#TAB$)
Next
Input()

View file

@ -0,0 +1,4 @@
irb(main):001:0> %w(north east south west).sample
=> "west"
irb(main):002:0> (1..100).to_a.sample(2)
=> [17, 79]

View file

@ -0,0 +1,6 @@
Function pick_random(arr)
Set objRandom = CreateObject("System.Random")
pick_random = arr(objRandom.Next_2(0,UBound(arr)+1))
End Function
WScript.Echo pick_random(Array("a","b","c","d","e","f"))