Author Topic: -={ Challenge }=- Subst at n  (Read 7277 times)

0 Members and 1 Guest are viewing this topic.

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: -={ Challenge }=- Subst at n
« Reply #15 on: March 29, 2010, 06:45:52 AM »
Some more fun  :-)

Code: [Select]
(defun Subst_at_n (item lst n / Sub)

  (defun Sub (a b c)
    (if b
      (cons
        (if (zerop c)
          (progn
            (defun Sub (a b c)
              (if b
                (cons (car b)
                      (Sub a (cdr b) c))))
            a)
          (car b))
        (Sub a (cdr b) (1- c)))
      (car b)))

  (Sub item lst n))

wizman

  • Bull Frog
  • Posts: 290
Re: -={ Challenge }=- Subst at n
« Reply #16 on: March 29, 2010, 09:33:40 AM »
Some more fun  :-)

Code: [Select]
(defun Subst_at_n (item lst n / Sub)

  (defun Sub (a b c)
    (if b
      (cons
        (if (zerop c)
          (progn
            (defun Sub (a b c)
              (if b
                (cons (car b)
                      (Sub a (cdr b) c))))
            a)
          (car b))
        (Sub a (cdr b) (1- c)))
      (car b)))

  (Sub item lst n))

Nice one Lee.  Just throwing this one for the record:
(acet-list-put-nth a lst n)

JohnK

  • Administrator
  • Seagull
  • Posts: 10637
Re: -={ Challenge }=- Subst at n
« Reply #17 on: March 29, 2010, 09:37:19 AM »
I dont understand this one at all.
http://www.theswamp.org/index.php?topic=32800.msg382733#msg382733

It's like its written in a different language.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: -={ Challenge }=- Subst at n
« Reply #18 on: March 29, 2010, 09:38:18 AM »

Nice one Lee.  Just throwing this one for the record:
(acet-list-put-nth a lst n)

Thanks Wiz, does documentation exist for the acet-* functions, I know there is a few listed over at AfraLISP, but is there a full list anywhere?

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: -={ Challenge }=- Subst at n
« Reply #19 on: March 29, 2010, 09:39:40 AM »
I dont understand this one at all.
http://www.theswamp.org/index.php?topic=32800.msg382733#msg382733

It's like its written in a different language.

Its the one above it written as anonymous functions... or 'obfuscated' as Michael would say  :evil:

wizman

  • Bull Frog
  • Posts: 290
Re: -={ Challenge }=- Subst at n
« Reply #20 on: March 29, 2010, 09:45:26 AM »
I haven't seen one Lee, i just do a search at vlide's appropos, then figure out the arguments. 

LE3

  • Guest
Re: -={ Challenge }=- Subst at n
« Reply #21 on: March 29, 2010, 10:49:06 AM »
In any of these challenges, do we've known who or which of the proposals has won? or do we just end up uploading all the possible options, for future reference? and decide which one is the best to fit the current needs, can we or who will judge them? or can we simple open a topic to place/write a function to do some specific task? and this can end being like a library reference - it is challenge the proper wording?

And yes I like these type of topics.

Sorry folks, got to ask, hope you won't mind, thanks.

 

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: -={ Challenge }=- Subst at n
« Reply #22 on: March 29, 2010, 11:03:09 AM »
I like to see the ingenious/interesting approaches to the problem, and really enjoy these kind of topics also  :-)

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: -={ Challenge }=- Subst at n
« Reply #23 on: March 29, 2010, 11:12:45 AM »
In any of these challenges, do we've known who or which of the proposals has won? or do we just end up uploading all the possible options, for future reference? and decide which one is the best to fit the current needs, can we or who will judge them? or can we simple open a topic to place/write a function to do some specific task? and this can end being like a library reference - it is challenge the proper wording?

And yes I like these type of topics.

Sorry folks, got to ask, hope you won't mind, thanks.

The winner is the body of knowledge that the swamp represents. I'm not interested in anything else, in particular nonsense like "Person A's submission is better than Person B's". That's the fastest way to have people stop posting their ideas or deleting posts when "better" solutions are posted. Sometimes we bench performance, and that's cool, because performance itself is only one of many things that constitutes a good algorithm. </opinion>
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: -={ Challenge }=- Subst at n
« Reply #24 on: March 29, 2010, 11:15:00 AM »
In any of these challenges, do we've known who or which of the proposals has won? or do we just end up uploading all the possible options, for future reference? and decide which one is the best to fit the current needs, can we or who will judge them? or can we simple open a topic to place/write a function to do some specific task? and this can end being like a library reference - it is challenge the proper wording?

And yes I like these type of topics.

Sorry folks, got to ask, hope you won't mind, thanks.

The winner is the body of knowledge that the swamp represents. I'm not interested in anything else, in particular nonsense like "Person A's submission is better than Person B's". That's the fastest way to have people stop posting their ideas or deleting posts when "better" solutions are posted. Sometimes we bench performance, and that's cool, because performance itself is only one of many things that constitutes a good algorithm. </opinion>

I couldn't have put it better, completely agree.

JohnK

  • Administrator
  • Seagull
  • Posts: 10637
Re: -={ Challenge }=- Subst at n
« Reply #25 on: March 29, 2010, 11:27:51 AM »
Challenges are all about learning in my opinion -i.e. "We are supposed to teach each other not beat each other". (c) Se7en inc.

I think LE3 is on to something though (each user should pick and choose the solution best to fit their need(s)). ...we need to add more comments and be maybe be more academic about our solutions.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

JohnK

  • Administrator
  • Seagull
  • Posts: 10637
Re: -={ Challenge }=- Subst at n
« Reply #26 on: March 29, 2010, 11:30:21 AM »
Code: [Select]
#include "stdafx.h"
#include <array>
#include <iostream>

using namespace std;
using namespace std::tr1;

int _tmain(int argc, _TCHAR* argv[])
{
  array<int,9> ints = {1,2,3,4,5,6,7,8,9};
  ints[2] = 9;
  for_each(ints.begin(), ints.end(), [](int n) { cout << n << " "; });
  cout << endl;
  system("pause");
  return 0;
}

I cant compile this: where/what is "stdafx.h"? I dont got that one.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: -={ Challenge }=- Subst at n
« Reply #27 on: March 29, 2010, 11:36:05 AM »
I cant compile this: where/what is "stdafx.h"? I dont got that one.

Compile it with visual c++ instead of gnu/gcc.

Subtitle: stdafx.h is a visual c++ centric pre-compiled header.

/guess
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

JohnK

  • Administrator
  • Seagull
  • Posts: 10637
Re: -={ Challenge }=- Subst at n
« Reply #28 on: March 29, 2010, 11:38:56 AM »
awe visual studio?! ...nope, never mind, not worth it.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: -={ Challenge }=- Subst at n
« Reply #29 on: March 29, 2010, 11:45:01 AM »
It was a parody / lampoon post anyway, direct element access is fundamental to arrays in C, C++, VB, Python ...
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst