1
0
Fork 0
mirror of https://gitlab.rlp.net/mobitar/julia_course.git synced 2024-11-16 13:28:10 +00:00

Finish advanced section about functions

This commit is contained in:
Mo8it 2022-03-29 04:22:53 +02:00
parent 01c2bdf9c1
commit f7be7a84f4
2 changed files with 1326 additions and 0 deletions

1261
Day_2/Day_2.jl Normal file

File diff suppressed because it is too large Load diff

65
Day_2/Tasks_day_2.jl Normal file
View file

@ -0,0 +1,65 @@
### A Pluto.jl notebook ###
# v0.18.4
using Markdown
using InteractiveUtils
# ╔═╡ ce10609f-94ee-4b39-95b8-a2573c60b0e7
md"""
# Useful functions
These are useful functions that might help you doing the tasks.
## `string(N)`
Converts a number `N` to a string.
Example:
string(42) == "42"
## `parse(TYPE, S)`
Parses a type `TYPE` out of string `S`.
Example:
parse(Int64, "-55") == -55
"""
# ╔═╡ 148125d2-aed5-11ec-2e5b-715891a04c69
md"""
# Universal pop
Define a function named `universal_pop` that takes a variable `var` and returns a version of it where the last "element" in this variable is removed.
`var` itself should NOT be modified!
The function `universal_pop` should be able to deal with (and only with) the following types of `var`:
- `AbstractVector`: `var=[1, 2, 3]` should return `[1, 2]`
- `AbstractString`: `var="Hello world!"` should return `"Hello world"`
- `Integer`: `var=51237` should return `5123`
- One more type of your choice if you think that this type would make sense with this function.
"""
# ╔═╡ 1dcfef68-48c3-4e54-9ac7-d0eba40621c8
# Your code starts here
# ╔═╡ 00000000-0000-0000-0000-000000000001
PLUTO_PROJECT_TOML_CONTENTS = """
[deps]
"""
# ╔═╡ 00000000-0000-0000-0000-000000000002
PLUTO_MANIFEST_TOML_CONTENTS = """
# This file is machine-generated - editing it directly is not advised
julia_version = "1.7.2"
manifest_format = "2.0"
[deps]
"""
# ╔═╡ Cell order:
# ╠═ce10609f-94ee-4b39-95b8-a2573c60b0e7
# ╟─148125d2-aed5-11ec-2e5b-715891a04c69
# ╠═1dcfef68-48c3-4e54-9ac7-d0eba40621c8
# ╟─00000000-0000-0000-0000-000000000001
# ╟─00000000-0000-0000-0000-000000000002