介绍

灵药我喜欢那种编程语言。
我真的很爱你,自动驾驶我创建了一个社区,名为

我们有一些来自海外的参与者。
其中之一卡米洛ElixirCL/wren-livebook喜欢移动。

ElixirCL/wren-livebook牙齿,一种叫做的编程语言活本它是使用智能手机上的移动它。

什么是?

我第一次发现。

Wren 是一种小型、快速、基于类的并发脚本语言
想想 Lua 大小的包中的 Smalltalk,带有少许 Erlang,并以熟悉的现代语法包装。

真是太神奇了!似乎很快wren-livebook を動かすことを楽しむwren-livebook を動かすことを楽しむwren-livebook を動かすことを楽しむ

System.print("Hello, world!")

class Wren {
  flyTo(city) {
    System.print("Flying to %(city)")
  }
}

var adjectives = Fiber.new {
  ["small", "clean", "fast"].each {|word| Fiber.yield(word) }
}

while (!adjectives.isDone) System.print(adjectives.call())

我会尝试移动

码头工人利用

git clone https://github.com/ElixirCL/wren-livebook.git

cd wren-livebook

docker run -p 8080:8080 -p 8081:8081 --pull always -u $(id -u):$(id -g) -v $(pwd):/data livebook/livebook

请使用浏览器毫不犹豫地访问。
访问:http://0.0.0.0:8080/?token=mymb5cototlctb5osmvxrybirqfqwkcd

*token的值每次都会变化,所以请使用终端上显示的准确值。

之后,打开wren.livemd并点击。
只需将@current @macos 更改为@current @unix码头工人在容器上运行。

我拍了一个视频。

我注意到了什么

我不明白一切。
我想介绍三个引起我注意的点。

  • ①原装智能电池
  • #{Wren.path()} #{path}
  • trap "rm -f #{path}" 0 2 3 15

①独创智能小区

看来您可以制作自己的 Smart Cell。
我不知道细节,但我认为这可能是相关的https://raw.githubusercontent.com/ElixirCL/wren-livebook/main/wren.livemd将其从

defmodule KinoGuide.WrenCell do
  use Kino.JS
  use Kino.JS.Live
  use Kino.SmartCell, name: "Wren script"

  @impl true
  def init(_attrs, ctx) do
    {:ok, ctx, editor: [attribute: "source", language: "javascript"]}
  end

  @impl true
  def handle_connect(ctx) do
    {:ok, %{}, ctx}
  end

  @impl true
  def to_attrs(_ctx) do
    %{}
  end

  @impl true
  def to_source(attrs) do
    quote do
      path = Temp.path!()
      File.write!(path, unquote(attrs["source"]))

      System.shell(
        """
        trap "rm -f #{path}" 0 2 3 15
        #{Wren.path()} #{path}
        """,
        into: IO.stream(),
        stderr_to_stdout: true
      )
      |> elem(1)
    end
    |> Kino.SmartCell.quoted_to_string()
  end

  asset "main.js" do
    """
    export function init(ctx, payload) {
      ctx.importCSS("main.css");

      root.innerHTML = `
        <div class="app">
          Wren script
        </div>
      `;
    }
    """
  end

  asset "main.css" do
    """
    .app {
      padding: 8px 16px;
      border: solid 1px #cad5e0;
      border-radius: 0.5rem 0.5rem 0 0;
      border-bottom: none;
    }
    """
  end
end

Kino.SmartCell.register(KinoGuide.WrenCell)
<!-- livebook:{"attrs":{"source":"System.print("Hello, world!")

class Wren {
  flyTo(city) {
    System.print("Flying to %(city)")
  }
}

var adjectives = Fiber.new {
  ["small", "clean", "fast"].each {|word| Fiber.yield(word) }
}

while (!adjectives.isDone) System.print(adjectives.call())"},"kind":"Elixir.KinoGuide.WrenCell","livebook_object":"smart_cell"} -->
<!-- livebook:{"attrs":{"source":"for (yPixel in 0...24) {
  var y = yPixel / 12 - 1
  for (xPixel in 0...80) {
    var x = xPixel / 30 - 2
    var x0 = x
    var y0 = y
    var iter = 0
    while (iter < 11 && x0 * x0 + y0 * y0 <= 4) {
      var x1 = (x0 * x0) - (y0 * y0) + x
      var y1 = 2 * x0 * y0 + y
      x0 = x1
      y0 = y1
      iter = iter + 1
    }
    System.write(" .-:;+=xX$& "[iter])
  }
  System.print("")
}"},"kind":"Elixir.KinoGuide.WrenCell","livebook_object":"smart_cell"} -->

#{Wren.path()} #{path}

#{Wren.path()} #{path}它运行一种名为
path 变量包含临时路径/1包含在 中获取的临时文件的路径。
对于#{Wren.path()}包含一个可执行二进制文件

wren <file_path>
关于它。

灵药例如,elixir sample.exs

trap "rm -f #{path}" 0 2 3 15

这是在#{Wren.path()} #{path} 之前写的。
您似乎删除了文件,但是在执行之前是否将其删除? ,0 2 3 15 是什么?已经成为。

这是我搜索trap 0 2 3 15 时找到的第一页。

简而言之,我将在这里将详细信息留给您执行编程语言后,我正在删除临时文件。
举止得体。
我被照顾得很好。
好的!卡米洛小姐! ! !

综上所述

ElixirCL/wren-livebook我喜欢移动
那是我学习的第一门编程语言。
我了解到您可以定义自己的智能单元。

卡米洛桑,谢谢!


原创声明:本文系作者授权爱码网发表,未经许可,不得转载;

原文地址:https://www.likecs.com/show-308628610.html

相关文章:

  • 2021-10-17
  • 2022-12-23
  • 2022-12-23
  • 2021-08-25
  • 2021-10-07
  • 2022-12-23
  • 2022-12-23
  • 2021-08-13
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-12
  • 2022-12-23
  • 2021-06-04
  • 2021-06-05
相关资源
相似解决方案