Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View file

@ -0,0 +1,61 @@
/* Rexx */
Do
placesList = sampleData()
call show placesList
say
sortedList = bubbleSort(placesList)
call show sortedList
say
return
End
Exit
-- -----------------------------------------------------------------------------
bubbleSort:
procedure
Do
il = arg(1)
sl = il~copy
listLen = sl~size
loop i_ = 1 to listLen
loop j_ = i_ + 1 to listLen
cmpi = sl[i_]
cmpj = sl[j_]
if cmpi > cmpj then do
sl[i_] = cmpj
sl[j_] = cmpi
end
end j_
end i_
return sl
End
Exit
-- -----------------------------------------------------------------------------
show:
procedure
Do
al = arg(1)
loop e_ over al
say e_
end e_
return
End
Exit
-- -----------------------------------------------------------------------------
sampleData:
procedure
Do
placesList = .array~of( ,
"UK London", "US New York", "US Boston", "US Washington", ,
"UK Washington", "US Birmingham", "UK Birmingham", "UK Boston" ,
)
return placesList
End
Exit

View file

@ -0,0 +1,72 @@
/* Rexx */
Do
placesList = sampleData()
call show placesList
say
sortedList = bubbleSort(placesList)
call show sortedList
say
return
End
Exit
-- -----------------------------------------------------------------------------
bubbleSort:
procedure
Do
il = arg(1)
sl = il~copy
itemCount = sl~size
loop label c_ until \hasChanged
hasChanged = isFalse()
itemCount = itemCount - 1
loop i_ = 1 to itemCount
if sl[i_] > sl[i_ + 1] then do
t_ = sl[i_]
sl[i_] = sl[i_ + 1]
sl[i_ + 1] = t_
hasChanged = isTrue()
end
end i_
end c_
return sl
End
Exit
-- -----------------------------------------------------------------------------
show:
procedure
Do
al = arg(1)
loop e_ over al
say e_
end e_
return
End
Exit
-- -----------------------------------------------------------------------------
sampleData:
procedure
Do
placesList = .array~of( ,
"UK London", "US New York", "US Boston", "US Washington", ,
"UK Washington", "US Birmingham", "UK Birmingham", "UK Boston" ,
)
return placesList
End
Exit
-- -----------------------------------------------------------------------------
isTrue: procedure
return (1 == 1)
-- -----------------------------------------------------------------------------
isFalse: procedure
return \isTrue()

View file

@ -0,0 +1,61 @@
/* Rexx */
Do
placesList. = ''
sortedList. = ''
call sampleData
call bubbleSort
do i_ = 1 to placesList.0
say placesList.i_
end i_
say
do i_ = 1 to sortedList.0
say sortedList.i_
end i_
say
return
End
Exit
/* -------------------------------------------------------------------------- */
bubbleSort:
procedure expose sortedList. placesList.
Do
/* Copy list */
do !_ = 0 to placesList.0
sortedList.!_ = placesList.!_
end !_
listLen = sortedList.0
do i_ = 1 to listLen
do j_ = i_ + 1 to listLen
if sortedList.i_ > sortedList.j_ then do
!_ = sortedList.j_
sortedList.j_ = sortedList.i_
sortedList.i_ = !_
end
end j_
end i_
return
End
Exit
/* -------------------------------------------------------------------------- */
sampleData:
procedure expose placesList.
Do
! = 0
! = ! + 1; placesList.0 = !; placesList.! = "UK London"
! = ! + 1; placesList.0 = !; placesList.! = "US New York"
! = ! + 1; placesList.0 = !; placesList.! = "US Boston"
! = ! + 1; placesList.0 = !; placesList.! = "US Washington"
! = ! + 1; placesList.0 = !; placesList.! = "UK Washington"
! = ! + 1; placesList.0 = !; placesList.! = "US Birmingham"
! = ! + 1; placesList.0 = !; placesList.! = "UK Birmingham"
! = ! + 1; placesList.0 = !; placesList.! = "UK Boston"
return
End
Exit