小编fun*_*ode的帖子

在终端中键入空字符

有没有办法在终端中输入空字符?

我想做的事情如下:

this is a sentence (null) test123
Run Code Online (Sandbox Code Playgroud)

linux terminal text

12
推荐指数
3
解决办法
3万
查看次数

在C中编译嵌入式lua

嘿大家我发现这个代码将Lua嵌入C中,我无法弄清楚如何让GCC编译它.我安装了Lua,但是如何链接Lua库?

这是我找到的代码:

            #include <stdio.h>
            #include "lua.h"
            #include "lualib.h"
            #include "lauxlib.h"

            /* lua interpreter */
            lua_State* l;

            int main () {
            int dofile;

            /* initialize lua */
            l = lua_open();

            /* load lua libraries */
            luaL_openlibs(l);

            /* run the hello.lua script */
            dofile = luaL_dofile(l, "hello.lua");

            if (dofile == 0) {
            /* call foo */
            lua_getglobal(l,"foo");
            lua_call(l,0,0);
            }
            else {
            printf("Error, unable to run hello.lua\n");
            }

            /* cleanup Lua */
            lua_close(l);

            return 0;
            }
Run Code Online (Sandbox Code Playgroud)

如何编译?

我正在尝试这个命令来编译

gcc -o embed_hello -L/users/etrosclair/Downloads/lua-5.1.4 -I/users/etrosclair/Downloads/lua-5.1.4 …
Run Code Online (Sandbox Code Playgroud)

c lua

5
推荐指数
1
解决办法
4081
查看次数

haskell设置数据类型

嘿大家我试图弄清楚如何在haskell中设置数据类型,但我无法弄明白,这是我到目前为止,我有点困惑

data Set a = Node a | List {
    list :: [a]
}deriving(Eq,Show,Ord)

insert :: Set Integer -> Set Integer -> Bool
insert (Node itemToInsert) (List list)
    |contains (List list) (Node itemToInsert) == False = List(list:(Node itemToInsert))


contains :: Set Integer -> Set Integer -> Bool
contains (List []) (Node numberToFind) = False
contains (List (x:xs)) (Node numberToFind)
    |x == (Node numberToFind) = True
    |otherwise = contains (List (xs)) (Node numberToFind)
Run Code Online (Sandbox Code Playgroud)

谢谢您的帮助!

haskell

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

TSQL将行转换为列

我有一个查询返回一些如下所示的数据:

Description
----------
Thing1
Thing2
Thing3
Thing4
Thing5
Thing6
Thing7
Run Code Online (Sandbox Code Playgroud)

我想让数据看起来像这样:

Desc1    Desc2  Desc3
-----    -----  -----
Thing1   Thing2 Thing3
Thing4   Thing5 Thing6
Thing7
Run Code Online (Sandbox Code Playgroud)

有人可以提供一个如何做到这一点的例子吗?

谢谢!

sql t-sql sql-server pivot

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

另一个haskell类型的困境

嘿大家我想写这个代码,我遇到了数据类型的问题

data Collection = Set [Int] deriving (Show)

remove :: Int -> Collection -> Collection
remove _ (Set []) = (Set [])
remove numberToRemove (Set (x:xs))
    |x == numberToRemove = (Set xs)
    |otherwise = Set ([x]:remove numberToRemove xs)
Run Code Online (Sandbox Code Playgroud)

我收到此错误,它的类型有问题:

 Couldn't match expected type `Int' with actual type `[t0]'
In the first argument of `(:)', namely `[x]'
In the first argument of `Set', namely
  `([x] : remove numberToRemove xs)'
In the expression: Set ([x] : remove numberToRemove xs)
Failed, modules loaded: …
Run Code Online (Sandbox Code Playgroud)

haskell

1
推荐指数
1
解决办法
220
查看次数

标签 统计

haskell ×2

c ×1

linux ×1

lua ×1

pivot ×1

sql ×1

sql-server ×1

t-sql ×1

terminal ×1

text ×1