V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  aijam  ›  全部回复第 8 页 / 共 20 页
回复总数  382
1 ... 4  5  6  7  8  9  10  11  12  13 ... 20  
2020-02-07 14:46:26 +08:00
回复了 pythonee 创建的主题 程序员 type 和 class 的区别是什么
In Assembly or C, type determines the interpretation of a sequence of memory and the operations that can be performed on it. For example, if you interpret 4 bytes of data as int, you can perform arithmetic operations with it; but if you interpret the same 4 bytes as char[4], you will be able to iterate over it with some indices.
Such idea can be found in many other languages. Another example is when you do "type casting", you are basically indicating the compiler to treat the same sequence of bytes with a different interpretation, such that a different set of operations can be applied.
So, how can you create your own type, i.e. define your own interpretation and the set of operations on a piece of data? That's where classes come into the picture. In general, you can consider a class as a recipe of a user-defined type, in contrast to the built-in types which are already predefined for you.
Surely, types and classes are much more profound concepts, especially when putting in the context of different languages. If you want to dive deeper on this topic, I think you should learn a little more about types and "type class" in Haskell, and maybe try to find the connection between "type class" in Haskell and "abstract class"/"interface" in the OO world. Also, compare them with "struct" in C/C++ and see how those languages provide their own mechanisms for abstraction.
觉得不值就卖给别人呗
@wutiantong 其实我也这么觉得,只是看看 greedy 分组啥效果 :D
@aijam 只能蒙着眼瞎写猜测 greedy 了。。。
@aijam 发现这个不对。
1. 所有元素组成一个 complete graph。
2. 每一对互斥的 pair 对应 graph 里面的一条 edge,一一删除。
3. 答案是:删除 edge 之后得到的 graph 的 connected component 个数。
2019-10-07 03:18:09 +08:00
回复了 rickyleegee 创建的主题 Python 如何使用 Python 从 json 返回算术表达式的结果?
啥叫递归?递归至少要调用自己阿。。。
2019-09-20 00:52:45 +08:00
回复了 kirara 创建的主题 程序员 C++的 Vector 容器中 string 类型元素可否用一种指针替代它?
for (auto &str: s) {
for (auto it = str.begin(); it != str.end() && !isspace(*it); it++) {
*it = toupper(*it);
}
cout << str << " ";
}
我觉得出题的人,要不语文有问题,要不逻辑有问题。a_delta, c_x, c_y 都不带定义的,全靠审题的人通过零星的描述和例子意会。工作生活中挺讨厌这种人,思路和语言组织都是乱的。
2019-08-07 15:11:31 +08:00
回复了 Mohanson 创建的主题 程序员 最近正在设计并实现一门编程语言(续)
@luoyou1014 lisp 情何以堪
2019-06-29 00:39:52 +08:00
回复了 akazure 创建的主题 程序员 高三美本 CS 党该怎么安排剩下的两个半月假期
Leetcode 题刷了吗
2019-06-14 03:49:39 +08:00
回复了 Harz 创建的主题 程序员 如何将代码写得优雅?
"因为每次看到自己写的 JAVA 代码像 CXK 写的 python 代码像 JAVA 代码那么啰嗦 写得 js 啥都不像" 所以这句话怎么断句?
2019-05-31 04:01:12 +08:00
回复了 tcdh 创建的主题 Python 关于 CPython 线程安全的问题
@tcdh sys.setswitchinterval(interval)
Set the interpreter ’ s thread switch interval (in seconds). This floating-point value determines the ideal duration of the “ timeslices ” allocated to concurrently running Python threads.

一秒太慢了
2019-05-31 03:39:52 +08:00
回复了 tcdh 创建的主题 Python 关于 CPython 线程安全的问题
GIL 了解下
2019-05-31 03:10:38 +08:00
回复了 ggicci 创建的主题 程序员 在家无聊在写一个记录和分享代码片段的网站 codelet.io
2019-05-29 11:50:52 +08:00
回复了 zxcjqyy 创建的主题 程序员 你们是怎么避免 list 为空
Effective Java, Item54: Return empty collections or arrays, not nulls
@0o0O0o0O0o unkown battleground
loop for 不就是 ruby 的 until do 么?
1 ... 4  5  6  7  8  9  10  11  12  13 ... 20  
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2731 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 37ms · UTC 12:32 · PVG 20:32 · LAX 04:32 · JFK 07:32
Developed with CodeLauncher
♥ Do have faith in what you're doing.