小编Thu*_*ura的帖子

如何将常见的lisp解释器嵌入到gui应用程序中

我想知道如何将一个lisp解释器嵌入到一个gui应用程序中,就像pyshell为Python做的那样.

lisp user-interface common-lisp

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

'(abc)和(list'a'b'c)有什么区别?

我正在阅读"在lisp上",并遇到了这段代码(我简化了一下).

CL-USER> (defun foo ()                                                          
           '(a b c))
FOO                                                                             
CL-USER> (foo)
(A B C)                                                                         
CL-USER> (nconc * '(D E))
(A B C D E)                                                                     
CL-USER> (foo)
(A B C D E) 
CL-USER> (defun foo ()                                                          
          (list 'a 'b 'c))
STYLE-WARNING: redefining FOO in DEFUN                                          
FOO                                                                             
CL-USER> (foo)
(A B C)                                                                         
CL-USER> (nconc * '(D E))
(A B C D E)                                                                     
CL-USER> (foo)
(A B C)
Run Code Online (Sandbox Code Playgroud)
  • 究竟是什么*意思?是以前的函数调用吗?它适合在现实世界的代码中使用吗?

  • 为什么要(nconc * '(D E))改变第一个foo函数的返回值?

  • 我一直以为(list 'a 'b …

lisp sbcl common-lisp

7
推荐指数
2
解决办法
562
查看次数

析构函数中的释放导致内存泄漏

我必须使用C++中的数组编写一个堆栈类模板.

是我的代码:

#include <iostream>

template <typename Type>
class Stack {
private:
  int top;
  Type items[];
public:
  Stack()  { top = -1; };
  ~Stack() { delete[] items; };
  void push(Type);
  bool isEmpty() const;
  Type pop();
  Type peek() const;
};

int main (int argc, char *argv[]) {
  Stack<double> st;
  return 0;
}

template<typename Type>
void Stack<Type>::push(Type item) {
  top++;
  if(top == sizeof(items) / sizeof(Type)) {
    Type buff[] = new Type[top];
    std::copy(items,items+top,buff);
    delete[] items;
    items = new Type[2*top];
    std::copy(buff,buff+top,items);
    delete[] buff;
  } …
Run Code Online (Sandbox Code Playgroud)

c++

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

在C中实现Tree的指针问题

我正在为我的任务实现一个avl树.

#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>

struct TreeNode {
  char *item;
  struct TreeNode *left;
  struct TreeNode *right;
  signed char balance;
};

typedef struct TreeNode Node;

void _print_avl (Node *, int , const char *);

Node * get_new_node (char *);
int avl_insert(Node *, char *);
void print_avl (Node *);
void avl_swr(Node*);

int main (int argc, char *argv[])
{
  Node *root = get_new_node("thura");
  avl_insert(root, "thur2");
  print_avl(root);

  avl_insert(root, "thur1");

  return 0;
}

int avl_insert(Node *root, char *item)
{
  assert(root);

  if( …
Run Code Online (Sandbox Code Playgroud)

c algorithm tree binary-tree

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

C++简单文件读取

我有一个名为f1.txt的文件,其内容为75 15 85 35 60 50 45 70

这是我读取每个整数并打印它们的代码.

#include <iostream>
#include <fstream>

using namespace std;
int main(int argc, char *argv[])
{
  fstream file("f1.txt", ios::in);
  int i;
  while(!file.eof()) {
    file >> i;
    cout << i << " ";
 }

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

但是当我编译并运行程序时,输出是75 15 85 35 60 50 45 70 70.为什么它读取最后一个整数两次?有线索吗?

c++

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

标签 统计

c++ ×2

common-lisp ×2

lisp ×2

algorithm ×1

binary-tree ×1

c ×1

sbcl ×1

tree ×1

user-interface ×1