Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    nothratal
    @nothratal
    this room still alive?
    I'm trying to get into objectpascal
    nothratal
    @nothratal
    Programming also a lot of ruby and I really got used to functional programming paradigm
    Ryan Potts
    @rpottsoh
    Yup, alive and well.... How can I be of assistance?
    nothratal
    @nothratal
    Are there any built in possibilities (or libraries) for functional programming? In ruby for instance I love to work like this:
    elements = [3,4,5,6,7,8,9,10]
    elements.find_all{|x| x>5}
    elements.reverse
    elements.map{|x| x*2 }
    elements.find_all{|x| x.even?}
    sure I could do everything with loops over several lines, but mostly it's just so much boilerplate code for such simple logics
    Ryan Potts
    @rpottsoh
    Yes there is. To me elements looks like it could be an array. But more likely a list. Some methods you've listed may or may not exists without having to add extra code. Some of what you describe is available "out of the box" more can be had by adding another library. Spring4d (open source) is an excellent example. The way the exercises are setup I think you will find you will not have to go too old school. Though you are welcome too, and if you do I'll point out better ways to accomplish the same task, if I am mentoring your work.
    If elements were an array I might look like so:
    var elements: TArray<integer> := [3,4,5,6,7,8,9,10];
    inline declaration and type inference is also available starting with Delphi 10.3.
    My syntax ^^ might be a little off but you get the idea hopefully.
    or another example:
    var myList := TList<integer>.create;
    myList.AddRange([3,4,5,6,7,8,9,10]);
    // do some stuff with myList......
    var myArray := myList.ToArray;
    myArray would be of type TArray<integer>.
    Ryan Potts
    @rpottsoh
    Delphi is more than Pascal. It is a dialect that supports all the basic features of Pascal.
    If you needed to loop over myArray and didn't care about an index you do so with a for loop like so:
    for var myInteger in myArray do
    begin
      // Do something with myInteger....
    end;
    I'm not sure what else to tell you at this point but to encourage you to check it out!
    Mark Edwards
    @SuzukiStumpy

    Trying out the Grains sample from the extended exercises, I'm struggling to get around an overflow condition within the method which computes the number of grains on square 64. The series is a progression computed by 2^(n-1) as far as I can tell (where n is the number of the square), so for square 64 the value should be 2^63 ... However, when executing the test for this particular instance, I'm getting the exception 'floating point invalid operation', although for all previous tests, the code is working fine.

    Code is here:

    Class Function Grains.square(n: Integer = 1): UInt64;
      begin
        result := Round(Ldexp(1, n-1));
      end;
    Ryan Potts
    @rpottsoh
    @SuzukiStumpy Round maxes out at Int64, UInt64 is needed here. Round and Ldexp are not needed to solve this exercise. Consider recursion in square.
    Mark Edwards
    @SuzukiStumpy
    Ah. That explains it then :) Been tearing my hair out (what little I have left) trying to get them working.
    Ryan Potts
    @rpottsoh
    @SuzukiStumpy an iterative loop in square will work too, but recursion makes the math SUPER simple and the code very simple.
    fishon-dev
    @fishon-dev
    Hello, I'm just starting out on exercism. I've installed and configured DUnitX as per the instructions but still get some unresolved unit name and undeclared identifier errors when I try to compile the HelloWorld exercise. Three of these errors refer to the DUnitX units but the first one states it cannot resolve System.SysUtils. Some of the DUnitX units that are used are recognized. Any idea what I'm missing here?
    Ryan Potts
    @rpottsoh
    @fishon-dev I think I need some more information. What version of Delphi are you using? Is it a brand new installation? Are you able to start a brand new VCL project, save it, and then run it? It will just display a blank form with X in the corner. If you are able to run a basic program like I just described then I recommend reviewing the DUnitX setup steps to make sure you didn't miss anything.
    fishon-dev
    @fishon-dev
    RAD Studio 2010. Based on my reading on this I think it has to do with this version not using fully qualified unit names
    fishon-dev
    @fishon-dev
    I posted my issue on Delphi-Praxis which gives more detail;
    https://en.delphipraxis.net/topic/2650-cannot-resolve-unit-name-dunitxloggersconsole/
    Ryan Potts
    @rpottsoh
    I have not checked this link, however I recommend installing the free community edition of Delphi.
    Netsu
    @WeebNetsu

    Hello everyone :)

    Delphi is a great language, it is just sad that you have to pay for it if you want the rights to publish anything you did with it :/

    Other than that, it is a great beginner programming language and ide to use/learn

    I look foreward to speaking more with everyone here about it :)
    Adrinalin
    @adrinalinadrina_twitter
    hello
    Ryan Potts
    @rpottsoh
    Hello
    Don Geiger
    @D.Geiger_gitlab
    Hello.
    I've been doing the exercises at exercism, and I've run into a problem with the hamming one. When I try compiling or doing a syntax check, I get the following errors on uHammingTests.pas: [dcc32 Error] uHammingTests.pas(56): E2076 This form of method call only allowed for class methods or constructor
    Don Geiger
    @D.Geiger_gitlab
    I decided I'd move on to another exercism task, this one being NucleotideCount. Here I get another error in the tests: [dcc32 Error] uNucleotideCountTests.pas(112): E2003 Undeclared identifier: 'EInvalidNucleotideException'. Any suggestions?
    Ryan Potts
    @rpottsoh
    Hi Don. I suggest submitting the solutions that you have so that myself or one of the other mentors can see for ourselves what you are seeing in order to help you more easily.
    Netsu
    @WeebNetsu
    There is now a Delphi programming crash course on YouTube... https://youtu.be/BqmJpFbRY2U
    YusufCakan
    @YusufCakan
    hi i have a case statement with range #128..#255, and I get an error "low bound exceeds high bound" how do I fix this
    Filip Toskovic
    @filiptoskovic
    Very peculiar... Tray to switch values #255..#128
    Ryan Potts
    @rpottsoh
    You would need to post a snippet of code so I can see better what might be the problem.
    case i of
      128..255: begin
                              // Do Stuff Here
                          end;
      0..127:     begin
                             // Do Different Stuff Here
                         end;
    end;
    Ryan Potts
    @rpottsoh
    Excuse the wonky formatting; that is not what it looked when I typed it. :smirk:
    Ryan Potts
    @rpottsoh
    @YusufCakan as long as i is of type char. Are you meaning to deal with characters #128 through #255 or integers 128 through 255? You seem to be indicating upper Ascii codes. Tell us more about what you are doing. Which Exercism exercise are you working on?
    acolburn
    @acolburn
    Many people have completed the Grains exercise, but I'm missing something. Wouldn't there be 2^63 grains on the 64th square of the chessboard? And isn't the maximum possible value for a variable of type UInt64 2^63 - 1?
    Ryan Potts
    @rpottsoh
    I think the help for Uint64 is wrong. The highest order bit is not a sign bit so 2^64 is fine. I believe if the type was signed you would end up with -1 but unsigned is the very large value that I am not going to retype here. Should be 2^64 on the 64th square btw.
    acolburn
    @acolburn
    Gotcha; thank you. Guess I haven't figure out my error message :-) [Also, isn't the first square 1 (2^0), 2nd square 2 (2^1), 3rd 4 (2^2), etc.?]
    acolburn
    @acolburn
    BTW, here's a link to the documentation: http://docwiki.embarcadero.com/Libraries/Rio/en/System.UInt64 [which says "The range for the UInt64 type is from 0 through 2^64-1."]
    acolburn
    @acolburn
    Last message: Round(Power(2,n)) - 1 created error. Square(n) - 1 works OK. Who knew? :-)
    ErikVoogt
    @ErikVoogt
    Hello
    I just started the delphi pascal course on exercism. Is it possible to use the Embarcadero RAD studio IDE?
    Ryan Potts
    @rpottsoh
    Yes, please do.
    odlarhg
    @odlarhg
    Hi all. I am new to Delphi and just getting started with Exercism. I have downloaded the Hello World project and if I compile it it works fine. What am I supposed to do now?. Sorry if my question is from a newbie, but that's who I really am. Thanks.
    Ryan Potts
    @rpottsoh
    You should then use the CLI to upload your solution to Exercism. You should already have the CLI installed and working properly since you were able to complete hello world.