小编Low*_*ong的帖子

你如何检查Elixir中的变量类型

在Elixir中,如何检查Python中的类型:

>>> a = "test"
>>> type(a)
<type 'str'>
>>> b =10
>>> type(b)
<type 'int'>
Run Code Online (Sandbox Code Playgroud)

我在Elixir中读到了类型检查器,例如'is_bitstring','is_float','is_list','is_map'等,但如果您不知道该类型是什么呢?

elixir

129
推荐指数
6
解决办法
5万
查看次数

在Elixir的ExUnit中,是否可以运行一次测试?

在python的nosetests中,您可以通过调用它的类然后调用测试名来指定运行一个测试,我们如何使用Elixir的ExUnit执行此操作?

elixir

56
推荐指数
3
解决办法
9572
查看次数

如何检查Scala中是否存在路径或文件

如何检查Scala中是否存在类似于Python的路径/文件?以下示例:

os.path.exists("/home")
Out[4]: True
Run Code Online (Sandbox Code Playgroud)

scala

55
推荐指数
4
解决办法
5万
查看次数

在Rust中反转一个字符串

这有什么问题:

fn main() {
    let word: &str = "lowks";
    assert_eq!(word.chars().rev(), "skwol");
}
Run Code Online (Sandbox Code Playgroud)

我收到这样的错误:

error[E0369]: binary operation `==` cannot be applied to type `std::iter::Rev<std::str::Chars<'_>>`
 --> src/main.rs:4:5
  |
4 |     assert_eq!(word.chars().rev(), "skwol");
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: an implementation of `std::cmp::PartialEq` might be missing for `std::iter::Rev<std::str::Chars<'_>>`
  = note: this error originates in a macro outside of the current crate
Run Code Online (Sandbox Code Playgroud)

这样做的正确方法是什么?

rust

21
推荐指数
2
解决办法
1万
查看次数

我可以在Elixir的同一个库中使用别名吗?

说我有一个函数的定义:

def rename(src, dst) do
   <do rename>
end
Run Code Online (Sandbox Code Playgroud)

在我的Elixir库中,我可以在同一个库中创建:

alias rename, as: mv  
Run Code Online (Sandbox Code Playgroud)

那么当用户可以在我的库中使用重命名和mv函数时?

elixir

11
推荐指数
2
解决办法
1543
查看次数

在 Makefile 中调用我自己的脚本后,我可以调用另一个目标吗?

在我调用自定义命令之后,我想在我的 makefile 中调用另一个目标:

first_target:
        do_some_stuff

second_target:
        call some command
        first_target
Run Code Online (Sandbox Code Playgroud)

当我像上面那样做时,它抱怨找不到 first_target 命令。我该怎么做呢?

gnu makefile

11
推荐指数
2
解决办法
9732
查看次数

如何告诉Cargo构建除main.rs之外的文件?

这是我的目录结构:

lowks@lowkster ~/src/rustlang/gettingrusty $ tree .
.
??? Cargo.lock
??? Cargo.toml
??? foo.txt
??? src
?   ??? boolean_example.rs
?   ??? function_goodbye_world.rs
?   ??? listdir.rs
?   ??? looping.rs
?   ??? main.rs
?   ??? pattern_match.rs
?   ??? write_to_file.rs
??? target
    ??? build
    ??? deps
    ??? examples
    ??? gettingrusty
    ??? native

6 directories, 11 files
Run Code Online (Sandbox Code Playgroud)

当我运行'货物构建'时,它似乎只是构建main.rs.我该如何更改Cargo.toml以构建其余文件?

rust rust-cargo

10
推荐指数
3
解决办法
2866
查看次数

如何使函数接受多种类型?

警告:去新手.我有这样的功能:

package main
import "flag"
import "fmt"

func print_out_type(x anything) string {
    switch v := x.(type) {
        case string:
             return "A string"
        case int32:
             return "An Integer"
        default:
             return "A default"
    }
}

func main() {
    wordPtr := flag.String("argument1", "foo", "a String")
    numPtr := flag.Int("argument2", 42, "an Integer")
    flag.Parse()
    fmt.Println("word: ", *wordPtr)
    fmt.Println("number: ", *numPtr)
}
Run Code Online (Sandbox Code Playgroud)

我试图根据类型返回不同类型的字符串.我只是陷入了如何编写一个接受不同类型参数的函数的问题.任何帮助表示赞赏.

go

9
推荐指数
2
解决办法
9710
查看次数

如何使用 yml 文件重新创建 conda 环境?

我的 conda 导出是这样完成的:conda env export --file environment.yml -n djangoenv

\n\n

文件本身如下所示:

\n\n
name: djangoenv\nchannels:\n- bioconda\n- anaconda-cluster\n- defaults\ndependencies:\n- anaconda-cluster::python-apt=0.8.5=py27_0\n- auto::pyumpf=0.1.1=py27_0\n- binstar::binstar=1.3.1=py27_0\n- bioconda::httplib2=0.9.2=py27_0\n- clyent=1.2.2=py27_0\n- conda-forge::backports.shutil_get_terminal_size=1.0.0=py27_0\n- conda-forge::ca-certificates=2016.2.28=0\n- conda-forge::ipython=4.2.0=py27_0\n- conda-forge::pexpect=4.1.0=py27_0\n- conda-forge::pickleshare=0.7.2=py27_0\n- conda-forge::ptyprocess=0.5.1=py27_0\n- conda-forge::python-pathlib2=2.1.0=py27_0\n- conda-forge::traitlets=4.2.1=py27_0\n- dateutil=2.4.1=py27_0\n- decorator=4.0.9=py27_0\n- ecdsa=0.13=py27_0\n- ipython_genutils=0.1.0=py27_0\n- jinja2=2.8=py27_0\n- kbroughton::ansible=2.0.0.2=py27_0\n- markupsafe=0.23=py27_0\n- openssl=1.0.2h=0\n- paramiko=1.16.0=py27_0\n- pip=8.1.1=py27_1\n- psycopg2=2.6.1=py27_1\n- pycrypto=2.6.1=py27_0\n- python=2.7.11=0\n- pytz=2016.4=py27_0\n- pyyaml=3.11=py27_1\n- readline=6.2=2\n- requests=2.10.0=py27_0\n- setuptools=20.7.0=py27_0\n- simplegeneric=0.8.1=py27_0\n- six=1.10.0=py27_0\n- sqlite=3.9.2=0\n- tk=8.5.18=0\n- travis::ansible-shell=0.0.2=py27_0\n- wheel=0.29.0=py27_0\n- yaml=0.1.6=0\n- zlib=1.2.8=0\n- pip:\n  - anaconda-client==1.3.1\n  - ansible==2.0.0.2\n  - ansible-lint==2.3.3\n  - ansible-shell==0.0.2\n  - backports.shutil-get-terminal-size==1.0.0\n  - coverage==4.0.3\n  - django==1.8\n  - django-angular==0.7.15\n  - django-countries==3.4.1\n  - django-easy-pdf==0.1.0\n  - django-money==0.7.4\n …
Run Code Online (Sandbox Code Playgroud)

python conda miniconda python-packaging

8
推荐指数
2
解决办法
1万
查看次数

使用私有API读取WiFi RSSI值

我正在开发一些不需要在App Store上的东西,所以我没有使用私有API来满足我的需求的问题我正在尝试使用MobileWiFi. framework to read the RSSI value for the wireless network the phone is currently connected to. I've included thehttps://github.com/Cykey/ios-reversed -headers/tree/c613e45f3ee5ad9f85ec7d43906cf69ee812ec6a/MobileWiFi`标题并使用桥接头将它们包含在我的swift项目中并编写如下代码.请原谅,我是新手.

import SystemConfiguration.CaptiveNetwork
typealias _WiFiManagerClientCreate = @convention(c) (CFAllocator, CInt) -> UnsafeRawPointer
typealias _WiFiManagerClientCopyDevices = @convention(c) (UnsafeRawPointer) -> CFArray
typealias _WiFiDeviceClientCopyProperty = @convention(c) (UnsafeRawPointer, CFString) -> CFPropertyList

if let libHandle = dlopen (Paths.ipConfiguration, RTLD_LAZY) {
        result = libHandle.debugDescription

        let _createManagerPtr = dlsym(libHandle, "WiFiManagerClientCreate")
        let _clientCopyDevicesPtr = dlsym(libHandle, "WiFiManagerClientCopyDevices")
        let _clientCopyPropertyPtr = dlsym(libHandle, "WiFiDeviceClientCopyProperty")

        if (_createManagerPtr != nil) …
Run Code Online (Sandbox Code Playgroud)

ios swift

8
推荐指数
2
解决办法
3479
查看次数

标签 统计

elixir ×3

rust ×2

conda ×1

gnu ×1

go ×1

ios ×1

makefile ×1

miniconda ×1

python ×1

python-packaging ×1

rust-cargo ×1

scala ×1

swift ×1