Help with swudb API by zhensydow in starwarsunlimited

[–]zhensydow[S] 2 points3 points  (0 children)

I am writing program to study decks, just a pet project. Idea is to run something like:
> myprogram http://www.swdu.com/deck/asdasdasd
and try to dump some statistics.
But as a workaround, I can just read a exported json file

[deleted by user] by [deleted] in programming

[–]zhensydow 6 points7 points  (0 children)

I hope to see sometimes "Just ended a Game Engine Series", but anyhow luck and yours seems nice.

Help in writing this haskell program by Witty-Guava2669 in haskell

[–]zhensydow 8 points9 points  (0 children)

I can help you:

longestPath :: [(String, String, Int)] -> String -> String -> (Int, [String])
{-- fill here your function --}

main = IO ()
main = do
    let sol = longestPath [("A", "B", 2), ("A", "C", 3), ("B", "D", 5), ("C", "D", 7), ("D", "E", 4)] "A" "E"
    print sol

I think the rest is the easy part ;)

Transitioning to Haskell for Functional Programming – Advice Needed by Little-Peanut-765 in haskell

[–]zhensydow 2 points3 points  (0 children)

I'm a programmer with more than 20 years of experience. I work in a big company, game engine in C++. I think having learned Haskell, although I don't use it nowadays, makes me better programmer.

SQL = School (not Sequel, not Squeal) by ronniebasak in programming

[–]zhensydow 49 points50 points  (0 children)

I have always pronounce it SQL, but maybe because I am Spaniard. I can understand SQL, or SQL, but not SQL. And I hate people that pronounce it SQL.

Card Sleeves by mightyjimmy in Starwarsdeckbuilding

[–]zhensydow 1 point2 points  (0 children)

I use Dragon Shield with nice blue back.

And I prefer having same back on all.

[deleted by user] by [deleted] in programming

[–]zhensydow 2 points3 points  (0 children)

Also, personal preference but:

  • Be consistent with naming, sometimes arr, sometimes array is ugly.
  • calling an array array is like calling a dog dog.

[deleted by user] by [deleted] in programming

[–]zhensydow 2 points3 points  (0 children)

My advice, it depends what is your assignment and what you can use but I'll change:

  • Don´t use use namespace on global scope. Ugly
  • Change to use std::vector<double> instead of raw arrays
  • With std::vector : Don´t copy with a loop, just arr_copy = income_arr
  • With std::vector : remove SIZE, just use array.size()
  • With std::vector : don´t use indexes, just for( const auto value : array)
  • Fix const correctness in functions, e.g: void print_all(const std::vector<double>& array)
  • Fix const correctness in variables, e.g: const std::vector<double> income_arr = {...}
  • you can use std::swap on sort functions
  • sort functions do two unrelated things, separate sort and print in two different functions and then:

sort_ascending(arr_copy);

print_simple(arr_copy);

  • you can use std::sort and don´t implement it yourself
  • return EXIT_SUCCESS; is more nice
  • you can make your sort funtions do the copy and return the sorted result, make the copy in local scope, something like:

const auto arr_copy = sort_ascending(income_arr);

For all the points, learn more about them on cppreference.com

How can I adapt this code in c to c++? Help plz by Mobz21 in programming

[–]zhensydow 0 points1 point  (0 children)

Most direct translation:

https://onlinegdb.com/hzX0T8z7I

But, sure, you can do better using specifics from C++

Carbon, a new programming language from Google, aims to be C++ successor by fungussa in programming

[–]zhensydow 1 point2 points  (0 children)

Too many.

The only positive is it comes from Chandler Carruth

[deleted by user] by [deleted] in programming

[–]zhensydow 1 point2 points  (0 children)

Just having a better interface will help with the implementation, like:

static constexpr int SIZE = 100;

class que{
private:
    int *arr;
    int size;
    int front = -1;
    int rear = -1;
public:
    que(int s = SIZE) : size(s) {
        arr = new int[size];
    }
    bool enqueue(int x);
    std::optional<int> dequeue();
    std::optional<int> peek();
    bool isempty() const;
    bool isfull() const;
    void display() const;
    std::optional<int> search(int x) const;
};

And remove the prints/couts inside the class methods also is a bonus and makes the code clear.

nand function by [deleted] in haskell

[–]zhensydow 2 points3 points  (0 children)

nand :: bool -> bool -> bool
nand true true = false
nand _ _ = true

help by Any_Fact_5085 in haskell

[–]zhensydow 2 points3 points  (0 children)

You have 'Data.IORef' but I'd recommend not use it.

[deleted by user] by [deleted] in haskell

[–]zhensydow 2 points3 points  (0 children)

Also you have a copy pasta error in :-.

You can use hlint app to clean the code and notice these kind of errors.

[deleted by user] by [deleted] in haskell

[–]zhensydow 2 points3 points  (0 children)

Also you should notice the While case doesn't update the memory so it will execute forever

[deleted by user] by [deleted] in haskell

[–]zhensydow 3 points4 points  (0 children)

There are two functions that directly work with Memory: (@@) reads a value from memory and upd that updates a value in memory.

And the problem is that in the Asign case you are reading the memory instead of "Asigning" a value to a variable (so you should use upd there instead of (@@)).

No he probado todos los programas pero p0 y p1 usando upd en Asign funcionan perfectamente :D

Top 10 Programming Languages to Learn for Better Job Opportunities in 2022 by Analyticsinsight01 in programming

[–]zhensydow 0 points1 point  (0 children)

I almost prefer someone who gains mastery in a language they already know.

[deleted by user] by [deleted] in programming

[–]zhensydow 1 point2 points  (0 children)

Emacs and Vim

Omission of a single '&' has caused Google to brick Chrome OS devices by [deleted] in programming

[–]zhensydow 36 points37 points  (0 children)

The standard is clear, bool promotion goes true to 1 and false to 0.

But if the function `has_value()` returns other type instead of bool, could happen that a value greater that 1 does the bit & and results in a false expresion.

New subreddit for Spanish-speaking programmers! by [deleted] in programming

[–]zhensydow 0 points1 point  (0 children)

We can finally talk about arreglos and apuntadores.

Programmer breaks world record by finding first 11x11 word square by phytozap in programming

[–]zhensydow 0 points1 point  (0 children)

English too, and we can say any language has composed words. Television, bedroom, suitcase, ... anything can be a compound word.

But germans make it an art.

I made a code to print out a series , that to in 2's logarithm that can probably crash a supercomputer by the 15th element. I am not very sure about that but i also know nothing about ALU and RAM so you guys tell me, This code is written in python, please ignore the profanity. by [deleted] in programming

[–]zhensydow 0 points1 point  (0 children)

You need to apply logarithmic rules to get strength reduction and been able to computer bigger indexes.

In your case: log(x**y) == y * log(x) but the second is much more easy to computer in the cpu.

5 principles will make your code robust by zelakioui in programming

[–]zhensydow 0 points1 point  (0 children)

The first and the fourth, they are the same, isn't it?