opensystemslab / struct.nim Goto Github PK
View Code? Open in Web Editor NEWPython-like 'struct' for Nim
License: MIT License
Python-like 'struct' for Nim
License: MIT License
Sorry, it's me again.
nim> import struct
nim> var a = unpack(">3I", "Hello World ")
nim> a
@[1214606444, 1864390511, 1919706144] == type seq[StructNode]
nim> pack(">3I", a)
Horld == type string
Also it would be a useful feature to pass a seq[int32]
to pack
.
useful function
Hi,
This code:
import struct
var packed_byte = pack("b", 5)
throws the following exception:
Traceback (most recent call last)
struct.nim(490) test
struct.nim(438) pack
struct.nim(326) pack_char
system.nim(3535) failedAssertImpl
system.nim(3527) raiseAssert
system.nim(2637) sysFatal
Error: unhandled exception: vars[ctx.offset].kind == StructChar [AssertionError]
>>> from struct import unpack
>>> unpack(">3I", b"Hello World ")
(1214606444, 1864390511, 1919706144)
nim> from struct import unpack
nim> unpack(">3I", "Hello World ")
@[(kind: StructInt, num: 1214606444), (kind: StructInt, num: 1214606444), (kind: StructInt, num: 1214606444)] == type seq[StructNode]
for Nim 0.18.1 :
.nimble\pkgs\struct-0.1.1\struct.nim(479, 27) Error: undeclared identifier: 'expr'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.