> 've started developing SymbolicNim

That is an interesting project. I tried some symbolic math myself when I was a 
young boy but fully failed and never tried again. : -)

I had just a short look at your code. Four spaces for indentation -- live would 
be so easy with tabs...

Some of your code looks a bit funny to me, but well it is hot hear and mybe I 
am a bit stupid today...
    
    
    proc isHalfMultiple(r: SymNumberType): bool =
        if r.den == 2 or r.den == 1: return true
        return false
    
    
    proc isHalfMultiple(r: SymNumberType): bool =
        r.den == 2 or r.den == 1
    
    
    Run
    
    
    proc pow*(r: SymNumberType, e: int): SymNumberType =
        if e < 0:
            result.num = r.den ^ (-e)
            result.den = r.num ^ (-e)
        else:
            result.num = r.num ^ e
            result.den = r.den ^ e
    
    proc pow*(r: SymNumberType, e: int): SymNumberType =
            result.num = r.den ^ (-e.abs)
            result.den = r.num ^ (-e.abs)
    
    
    Run
    
    
    proc contains*(tree: SymbolicExpression, kind: ExprKind): bool 
{.noSideEffect.} =
        if tree.children.len == 0:
            return false
        else:
            for child in tree.children:
                if child.kind == kind:
                    return true
            return false
    proc contains*(tree: SymbolicExpression, kind: ExprKind): bool 
{.noSideEffect.} =
            for child in tree.children:
                if child.kind == kind:
                    return true
    
    
    Run
    
    
    proc survey(trees: openArray[SymbolicExpression]): SurveyObject =
        for e in ExprKind:
            result[e] = (count: 0, indexes: newSeqOfCap[int]((trees.len / 
2).toInt))
        for i in 0 .. trees.high:
            case trees[i].kind
            of exprConstant:
                inc result[exprConstant].count
                result[exprConstant].indexes.add(i)
            of exprVariable:
                inc result[exprVariable].count
                result[exprVariable].indexes.add(i)
            of exprFactors:
                inc result[exprFactors].count
                result[exprFactors].indexes.add(i)
            of exprTerms:
                inc result[exprTerms].count
                result[exprTerms].indexes.add(i)
            of exprExponent:
                inc result[exprExponent].count
                result[exprExponent].indexes.add(i)
            of exprFuncCall:
                inc result[exprFuncCall].count
                result[exprFuncCall].indexes.add(i)
    
    proc survey(trees: openArray[SymbolicExpression]): SurveyObject =
        for e in ExprKind:
            result[e] = (count: 0, indexes: newSeqOfCap[int]((trees.len / 
2).toInt))
        for i in 0 .. trees.high:
            let x = trees[i].kind
            inc result[x].count
            result[x].indexes.add(i)
    
    
    Run

What do you think?

Reply via email to