开始使用免费开始使用

Appending arrays

You are once again examining your run times. Since you last looked at these values, you have been on more runs. You have also realized that you made a mistake in recording your run times previously - you accidentally added the time of your last run twice.

You want to remove this duplicated value and add your new run times to the array.

The array of your previous run times, named runtimes, and the array of your new run times, named new_runtimes, are already defined for you.

Remember that functions that end with an ! modify their arguments. Other functions will not do this.

本练习是课程的一部分

Introduction to Julia

查看课程

练习说明

  • Use the pop!() function to remove the last value of the runtimes array to get rid of the duplicated value.
  • Use the append!() function to add your new run times to the runtimes array.

交互式实操练习

通过完成这段示例代码来试试这个练习。

runtimes = [35.1, 34.0, 34.31, 32.8, 32.04, 33.66, 32.41, 32.32, 33.37, 31.4, 31.4];
new_runtimes = [30.44, 31.21, 30.38, 30.52, 30.2];

# Remove the duplicated value
duplicated_value = ____

# Append new runtimes and new_runtimes
____

println("Duplicated value $duplicated_value")
println("All run times: $runtimes")
编辑并运行代码