เห็นที่นี่มีคนเล่นภาษาจำพวก script กันเยอะเลยมาถามว่า ตอนนี้มีภาษาไหนที่มี syntax จัดการกับพวกตัวแปรจำพวก list, tree, record ที่มองแล้วดูง่าย ๆ มั้งครับ
เช่นต้องการเอา tree สอง tree มาต่อกันแบบใช้แค่ operator เดียว, convert จาก data type นึงไปเป็นอีกแบบหนึ่งเช่น array -> vector, list -> map
อยากได้ syntax ที่แบบว่าเขียนง่ายให้ user เรียนรู้ง่าย
เล่น native
ZetaSolid Fri, 29/08/2008 - 18:18
เล่น native อย่าง C++ ก็ไม่ยากนะครับเช่น เอา list ของ int มาต่อกับ vector ของ double ก็ต่อได้เลย ด้วยคำสั่ง insert ลอง ไปอ่านดูนะครับ
#include < iostream > #include < vector > #include < list > #include < map >
int main( int argc, char ** argv ) { std::vector< double > v; std::list< int > l;
for( int i = 0 ; i < 3 ; ++i ) { v.push_back( i + 0 ); l.push_back( i + 3 ); }
v.insert( v.end( ), l.begin( ), l.end( ) );
int n = (int)v.size( ); for( int i = 0 ; i < n ; ++i ) std::cout << v[ i ] << std::endl;
return 0; ,
อยากให้เป
IceDagger Fri, 29/08/2008 - 18:48
In reply to เล่น native by ZetaSolid
อยากให้เป็ฯในรูปแบบ script มากกว่าครับ ผมเองก็เขียน C/C++ อยู่กับ script บางตัวเช่น Tcl/VBscript/JavaScript/PHP/Make แต่ก็ยังรู้สึกไม่ถูกใจเท่าไหร่กับ syntax ของภาษาพวกนี้ (จริง ๆผมอยากให้มันดูง่ายแบบ พวก matlab script แต่อันไหนมันเน้นไปแต่ arithmetic ซะเยอะ
ยังไงก็ขอบคุณสำหรับความเห็น
ต้องลอง ruby
hereblur Fri, 29/08/2008 - 19:15
ต้องลอง ruby กับ python ครับ
+1 ruby,python,
IPorsut Fri, 29/08/2008 - 19:38
In reply to ต้องลอง ruby by hereblur
+1 ruby,python, หรือจะลอง haskell ดูก็ดีครับ
groovy,
noyzilla Sat, 30/08/2008 - 02:14
In reply to +1 ruby,python, by IPorsut
groovy, mathematica
Noyzi!!a's Blog
ผมว่า
bow_der_kleine Sat, 30/08/2008 - 08:19
ผมว่า เป็นกระทู้ที่น่าจะไปอยู่ใน Programming Problems ครับ
Python มี list, dictionary, tuple มาให้ในตัว (builtin type) ส่วน set อยู่ใน builtin module ส่วน array ต้องติดตั้ง numpy เพิ่มเติม
# list to tuple
a = tuple([1,2,3,4,"a string"])
# tuple to list
b = list(a)
# 2 lists to dict
c = dict(zip(a, b[::-1]))
# dict to list
d = c.items()
# combine 2 lists
e = d+b
# reverse list
f = e[::-1]
# sort list
g = sorted(f)
# list to array
from numpy import *
h = array(range(10))
# array addition
i = h+h
# array to list
j = list(i)
# combine 2 arrays
k = append(i,h)
# array to matrix
l = matrix(h)
# matrix multiplication (T = transpose)
m = l*l.T
โดยคร่าว ๆ ก็ประมาณนี้ครับ ส่วนมากใช้ operation เดียวทำงานหนึ่งอย่าง พวกภาษาสคริปต์ก็ได้เปรียบตรงนี้แหละครับ
BioLawCom.De