In SML (Standard ML), you can create an empty list using the []
syntax. To create a list filled with dummy numbers, you can use the ::
(cons) operator to prepend elements to the list.
Here's an example in SML:
286 chars10 lines
Output:
main.rb29 chars3 lines
In Ruby, you can also create an empty list using the []
syntax. To create a list filled with dummy numbers, you can use the Array.new
method with a block.
Here's an example in Ruby:
main.rb225 chars10 lines
Output:
main.rb29 chars3 lines
Note that in Ruby, the indices start from 0. So, we use i + 1
to generate dummy numbers.
gistlibby LogSnag