أضف مشاركة إلى الموضوع: مرحبا
اضغط هنا للدخول
يمكنك إختيار أيقونة لرسالتك من هذه القائمة
سيتم تحويلها www.example.com إلى [URL]http://www.example.com[/URL].
رد: مرحبا بس اخر سؤال انا لئيت هدول وين بدي احطهم #ifndef UNIFY_HH #define UNIFY_HH UNIFY_HH #include "../command.hh" #include <string> class Unify : public Command { public: void doit( const std::string &s ); void help( const std::string &s ) const; void description() const; }; #ifndef PLAYLIST_HH #define PLAYLIST_HH PLAYLIST_HH #include <string> #include <vector> #include <stdio.h> #include "track.hh" #define MAXFILENAMELENGTH BUFSIZ class Playlist : public std::vector<Track> { public: Playlist(); void addPath( const std::string &path ); void addPath( const std::vector<std::string> &path ); void addPlaylist( std::string filename ); void addPlaylist( const std::vector<std::string> &filenames ); void savePlaylist( std::string filename ); void positiveFilter( const std::string &flt ); void positiveFilter( const std::vector<std::string> &flt ); void negativeFilter( const std::string &flt ); void negativeFilter( const std::vector<std::string> &flt ); void loadNegativeFilter( const std::string &filename ); void loadPositiveFilter( const std::string &filename ); void loadNegativeFilter( const std::vector<std::string> &filenames ); void loadPositiveFilter( const std::vector<std::string> &filenames ); void shuffle(); Track operator++(); Track operator++( int ) { return ++(*this); } Track operator--(); Track operator--( int ) { return --(*this); } Track operator*() const; unsigned int pos() const; /* position defaults to current track */ const_iterator ConstIterator( int pos = -1 ) const; iterator Iterator( int pos = -1 ); void jump(int newpos); private: std::vector<std::string> loadFilterFile( const std::string &filename ); void addTrack( const std::string &path, const std::string filename ); void addTrack(FILE* fp); int current; }; extern Playlist* plist; #endif
رد: مرحبا
رد: مرحبا شكرا كتير كتيييير اسفه غلبتك
رد: مرحبا اكيد رح يعطي error لأنه في تضمين لملفات مش موجودة و شكلك ما لقيتيها مرفقة مع الكود الي لقيتيه بالنت و الملفات المفقودة هي : كود: #include "unify.hh" #include <stack> #include "../playlist.hh" #include "../iosubsys/output.hh"
#include "unify.hh" #include <stack> #include "../playlist.hh" #include "../iosubsys/output.hh"
رد: مرحبا شكرا الك انا بصراحه عم ادور على كودات من النت وكلهم بيعطي error ولازم بكرا اسلم الكود بدي اغلبك شفلي هاد الكود 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 #include "unify.hh" #include <stdio.h> #include <string> #include <stack> #include "../playlist.hh" #include "../iosubsys/output.hh" void Unify::doit( const std::string &s ) { std::stack<Playlist::iterator> stck; for (Playlist::iterator it = plist->begin(); it != plist->end(); it++) { Playlist::const_iterator at = it; for ( at++; at != plist->end(); at++) if (it->filename() == at->filename()) { stck.push(it); } } while (!stck.empty()) { plist->erase(stck.top()); stck.pop(); } } /* map<string,Playlist::const_iterator> cmp; for (Playlist::const_iterator it = plist->begin(); it != plist->end(); it++) if (cmp.count(it->filename())>0) { printf("removing %s (=%s)\n",it->title().c_str(),cmp[it->filename()]->title().c_str()); plist->erase(it); } else cmp[it->filename()]=it; } */ void Unify::help( const std::string &s ) const { output->printf("format: unify\n"); output->printf("description: removes multiple entries in playlist\n"); } void Unify::description() const { output->printf("removes multiple entries in playlist\n"); }
رد: مرحبا بصراحة الكود مش مفهوم بعدين اختي انا لاحظت انك بتستدعي من خلال object بس الكلاس مش موجود عشان نحكم على انه صح او غلط يعني بصراحة استفسارك مبهم و غير واضح + الكود مش كامل
مرحبا السلام عليكم ممكن اطلب مساده منكم بدي code unification بلغه c++ وهل هاد الcod صح ولا لأ؟ > // generate MGU of terms t1, t2 > // return 0 if failure (t1, t2 don't unify) > // > // the simple stacked, abstract algorithm is keep from > // 'The Art Of Prolog' by Sterling & Shapiro > // > int UnifyStack::work(Term t1, stkpos envp1, Term t2, stkpos envp2) > { > termPair *tp; > for ( ; ; ) > { > if (t1.type(f_VAR)) // here be dragons! > { > if (Var(t1) == ANONYM_IX) > goto next; > stkpos ix1 = Var(t1) + envp1; > if ((t1 = vs->getvar(ix1, &envp1, &ix1)).type(f_NOTERM)) > { > if (t2.type(f_VAR)) > { > if (Var(t2) == ANONYM_IX) > goto next; > ts->bind(ix1); > stkpos ix2 = Var(t2) + envp2; > if ((t2 = vs->getvar(ix2, &envp2, &ix2)).type(f_NOTERM)) > { > if (ix1 != ix2) > vs->setshare(ix1, ix2); > } > else > vs->setvar(ix1, t2, envp2); > } > else > { > ts->bind(ix1); > vs->setvar(ix1, t2, envp2); > } > goto next; > } > } > if (t2.type(f_VAR)) > { > if (Var(t2) == ANONYM_IX) > goto next; > stkpos ix2 = Var(t2) + envp2; > if ((t2 = vs->getvar(ix2, &envp2, &ix2)).type(f_NOTERM)) { > ts->bind(ix2); > vs->setvar(ix2, t1, envp1); > goto next; > } > } > if (!t2.type(t1.type())) > return 0; > switch (t1.type()) > { > case f_ATOM: > case f_INT: > if (TermData(t1) != TermData(t2)) > return 0; > break; > case f_DOUBLE: > if (Double(t1) != Double(t2)) > return 0; > break; > case f_STRUCT: > { > Term *pa1, *pa2; > int na1, na2; > if (t1.structData(&pa1, &na1) != t2.structData(&pa2, &na2) || > na1 != na2) > return 0; > for (int i = na1 - 1; i >= 0; i--) > { > tp = push(); > tp->t1 = pa1[i]; > tp->i1 = envp1; > tp->t2 = pa2[i]; > tp->i2 = envp2; > } > check_overflow(); > } > break; > case f_LIST: > if (t1.LNULL() && t2.LNULL()) > goto next; > if (!t1.LNULL() && !t2.LNULL()) > { > const List& l1 = t1, &l2 = t2; > tp = push(); > tp->t1 = l1.tail(); > tp->i1 = envp1; > tp->t2 = l2.tail(); > tp->i2 = envp2; > tp = push(); > tp->t1 = l1.head(); > tp->i1 = envp1; > tp->t2 = l2.head(); > tp->i2 = envp2; > check_overflow(); > } > else > return 0; > break; > case f_SYSDATA: > if (!SysDataPtr(t1)->unify(t2)) > return 0; > break; > default: > ASSERT(0); > } > next: > if (free == 0) > return 1; > tp = v + --free; > t1 = tp->t1; > envp1 = tp->i1; > t2 = tp->t2; > envp2 = tp->i2; > } > }
مرحبا
قوانين المنتدى