Programowanie w systemie UNIX/Julia

Instalacja edytuj

 sudo snap install julia  # version 1.0.4

or

 sudo apt  install julia  # version 1.4.1+dfsg-1

uruchamianie edytuj

  • bash
  • repl
  • docker[1]
  • GoogleCollab [2]

bash edytuj

W terminalu wpisujemy

 julia

Przykładowy wynik:

               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.4.1
 _/ |\__'_|_|_|\__'_|  |  Ubuntu   julia/1.4.1+dfsg-1
|__/                   |


lub z argumentami:[3]

 julia script.jl arg1 arg2...


Kończenie programu:[4]

  • Ctrl-d

REPL edytuj

Po uruchomieniu julii w terminalu wpisujemy

 include("hello_world.jl")

inaczej:[5]

 julia> include("path/to/script-name.jl")


tryby edytuj

REPL ma 5 trybów wprowadzania ( ang. prompt modes )[6]

  • Julian mode( domyślny)
  • help
  • shell
  • search
  • reverse search

katalogi edytuj

Aktualny katalog roboczy: w REPL wpisujemy:[7]

 pwd()

przykładowy wynik :

 "/home/a"

Katalog domowy :

 homedir()

"

moduły edytuj

GUI edytuj

  • Makie : Visualizations and plotting in Julia, docs and git repo


CUDA edytuj

 isinstalled(pkg::String) = any(x -> x.name == pkg && x.is_direct_dep, values(Pkg.dependencies()))
 pk = ["CUDA"]
 using Pkg; for p in pk; isinstalled(p) || Pkg.add(p); end
 Pkg.test("CUDA")

Pkg edytuj

Pkg zawiera własny REPL.[8]

Otwórz Pkg REPL, naciskając ] w Julia REPL. Aby wrócić do Julia REPL, naciśnij klawisz Backspace lub ^ C.

GR edytuj

Dodawanie modułu w trybie Julia REPL:

 Pkg.add("GR")

lub w trybie Pkg REPL-mode:

 add GR

plots edytuj

" from https://juliabyexample.helpmanual.io/"


"https://discourse.julialang.org/t/how-to-use-pkg-dependencies-instead-of-pkg-installed/36416/13"
isinstalled(pkg::String) = any(x -> x.name == pkg && x.is_direct_dep, values(Pkg.dependencies()))

pk = ["Plots"]
using Pkg; for p in pk; isinstalled(p) || Pkg.add(p); end


using Plots

" pwd() "
cd("Dokumenty/julia/")


# plot some data
Plots.plot([cumsum(rand(500) .- 0.5), cumsum(rand(500) .- 0.5)])

# save the current figure in 
Plots.savefig("plots.svg")
# .eps, .pdf, & .png are also supported
# we used svg here because it respects the width and height specified above

RootsAndPoles edytuj

Pakiet RootsAndPoles jest na juliahub


Instalacja

using Pkg

PKG.add("RootsAndPoles");

skróty klawiaturowe edytuj

Opis ( ang. Key bindings)[9]

Program control

  • ^D Exit (when buffer is empty)
  • ^C Interrupt or cancel
  • ^L Clear console screen
  • Return/Enter, ^J New line, executing if it is complete
  • meta-Return/Enter Insert new line without executing it
  • ? or ; Enter help or shell mode (when at start of a line)
  • ^R, ^S Incremental history search

Gdzie Meta oznacza Alt

Zobacz również edytuj

Żródła edytuj

  1. docker: Julia
  2. ISTE NITH : Julia_on_the_GPU/mandlebrot/
  3. julia lang manual: getting-started
  4. stackoverflow question: how-to-alias-quit-to-quit
  5. stackoverflow questionrunning-julia-jl-files
  6. docs julialang : stdlib REPL
  7. stackoverflow question : setting-working-directory-julia-versus-r
  8. docs of julialang : Pkg getting-Started
  9. docs.julialang.org: Key-bindings