Skip to content

Latest commit

 

History

History
305 lines (226 loc) · 5.6 KB

README.md

File metadata and controls

305 lines (226 loc) · 5.6 KB

1. CScripting

Visualization of the codebase

GitHub stars Nuget Nuget GitHub release

1.1. Instruction

write c# script like python

!!! tip 思路 我们主要是想在 C# 实现 Python 的内置函数,并C# 中可以直接使用, 以便提高简单脚本的编写效率。

!!! tip 欢迎 ❤️
    欢迎 任何 PR

!!! tip idea We aim to implement the built-in function of python in C# and direct use in C# to improve the effect.

!!! tip **Welcome** ❤️
    welcome any pull request

1.2. Recent Changelog

  • time: 2023年5月15日
  • version: 1.0.6
  • log:
    1. change readme
    2. add help function
    3. add dir function
    4. fix trim print() last sep

more information, see CHANGELOG.md

1.3. Demo

  • Code

🔗 C#

#r "nuget: CScripting, *"
using static CScripting;

var addr = 0x12345678;
var addrr = hex(addr);

print(addr); // 305419896
print(addrr);

var val = 0x12345678;
var valr = bin(addr);

print(val); // 305419896
print(valr);

var c = new int[] { 0, 1, 2, 3, 4, 5, 6, 7 };

print(c);
print(c, sep:"\t");

🔗 Python

#r "nuget: CScripting, *"


addr = 0x12345678
addrr = hex(addr)

print(addr) # 305419896
print(addrr)

val = 0x12345678
valr = bin(addr)

print(val); # 305419896
print(valr)

c = [0, 1, 2, 3, 4, 5, 6, 7]

print(c)
print(c, sep="\t")
  • Output

C#

305419896
0x12345678
305419896
0b10010001101000101011001111000
{ 0, 1, 2, 3, 4, 5, 6, 7}
0	1	2	3	4	5	6	7

Python

305419896
0x12345678
305419896
0b10010001101000101011001111000
[0, 1, 2, 3, 4, 5, 6, 7]
[0, 1, 2, 3, 4, 5, 6, 7]
~$ dotnet-script
> #r "nuget: CScripting, *"
> using static CScripting;
> hex(1024)
"0x400"
> print("Hello CScripting")
Hello CScripting

1.5. Extended function list

  • MyOwn
    • load()
    • unload()

1.6. Extended function list like Matlab

  • coming
    • ???
    • ????

1.7. Python Built-in function list

  • A

  • B

  • C

    • callable()
    • chr()
    • classmethod()
    • compile() **
    • complex() **
  • D

    • delattr()
    • dict()
    • dir() *
    • divmod()
  • E

    • enumerate()
    • eval()
    • exec()
  • F

    • filter()
    • float()
    • format()
    • frozenset()
  • G

    • getattr()
    • globals()
  • H

  • I

    • id()
    • input()
    • int()
    • isinstance()
    • issubclass()
    • iter()
  • L

    • len()
    • list()
    • locals()
  • M

    • map()
    • max()
    • memoryview()
    • min()
  • N

    • next()
  • O

  • P

  • R

    • range()
    • repr()
    • reversed()
    • round()
  • S

    • set()
    • setattr()
    • slice()
    • sorted()
    • staticmethod()
    • str()
    • sum()
    • super()
  • T

    • tuple()
    • type()
  • V

    • [ ]vars()
  • Z

    • zip()
  • misc

    • _
    • __import__()
    • ???